I have three tables:
1-clients:
cli-no
cli-name
2-movies:
mov-no
mov-name
3-bills:
bill-no
cli-no ( fk from clients table)
mov-no ( fk from movies table)
I try to make a query to have this result:
cli-no | cli-name | bill-no | mov-name
For the clients either they has bills or not (null value for clients with no bills)
I tried this:
mysql> select clients.*,bill-no,mov_name
-> from
-> clients left join bills on clients.cli_no=bills.cli_no
-> , movies where bills.mov_no=movies.mov_no;
It gives me data for clients that has bills and not for all the clients.
And this one
mysql> select clients.*,bills.bil_no,movies.movie_name
-> from
-> clients left join bills on
-> clients.cli_no=bills.cli_no
-> movies left join bills on
-> movies.mov_no=bills.mov_no;
I have this error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
to use near 'movies left join bills on
movies.mov_no=bills.mov_no' at line 5
How can I fix this point?
1-clients:
cli-no
cli-name
2-movies:
mov-no
mov-name
3-bills:
bill-no
cli-no ( fk from clients table)
mov-no ( fk from movies table)
I try to make a query to have this result:
cli-no | cli-name | bill-no | mov-name
For the clients either they has bills or not (null value for clients with no bills)
I tried this:
mysql> select clients.*,bill-no,mov_name
-> from
-> clients left join bills on clients.cli_no=bills.cli_no
-> , movies where bills.mov_no=movies.mov_no;
It gives me data for clients that has bills and not for all the clients.
And this one
mysql> select clients.*,bills.bil_no,movies.movie_name
-> from
-> clients left join bills on
-> clients.cli_no=bills.cli_no
-> movies left join bills on
-> movies.mov_no=bills.mov_no;
I have this error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax
to use near 'movies left join bills on
movies.mov_no=bills.mov_no' at line 5
How can I fix this point?