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"

do something like this (not exactly like this)

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.