0

Hey,
I've just started using mysql and I have som problem with JOIN.

I have table1 and table2 and I would like to join these two on table1.col1 and table2.col1 to eliminate all identical rows. In addition I need to have a WHERE statement on table1.

This is my attempt:

"SELECT * FROM table1 WHERE col1.var1 = 'value' JOIN table2 ON table1.col1=table2.col1"
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by saurav.prasad28
0

do something like this (not exactly like this)

"SELECT * FROM table1 LEFT JOIN table2 ON table1.col1=table2.col2 WHERE table1.col1=$var1";
0

Hi

suppose i have two table book and authors

select * from book;

"book_id" "title" "first_name" "description" "publisher_id"
"1" "Let us c" "Graham" "1" "1"
"2" "Maths" "greee" "1" "2"
"3" "Oparating system" "prasad" "39" "3"
"4" "Micro processor" "jamej" "0" "4"
"5" "Micro processor" "robert" \N "5"

select * from authors;

"book_id" "author_last" "first_name" "country"
"1" "Greene" "Graham" "United Kingdom"
"2" "graham" "greee" "germany"
"3" "saurav" "prasad" "India"

There is two table and you have to retrived only three column for both the table
for example you have FETCHed title and first_name from "book" and in "author" you have retrived only country
column then your querry will be like this

select book.title,book.first_name,authors.country from
book left join authors On book.book_id = authors.book_id

and for your example you used a where clause it is not like that see the querry below here i use where command also

select book.title,book.first_name,authors.country from
book left join authors On book.book_id = authors.book_id where book.first_name = 'graham'

MARKED AS SOLVED IF IT'S HELP YOU.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.