954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with JOIN

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"
joeltonnberg
Newbie Poster
8 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

do something like this (not exactly like this)

"SELECT * FROM table1 LEFT JOIN table2 ON table1.col1=table2.col2 WHERE table1.col1=$var1";
affnetguru
Newbie Poster
5 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

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.

saurav.prasad28
Newbie Poster
11 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You