How to join two tables in sqlCE

Posted by Chaithragm under Sql Server on 3/22/2013 | Points: 10 | Views : 2198 | Status : [Member] | Replies : 1
Hi
im joining two tables ,its displaying all the rows from 2 tables
the results must filter by where condition..
how to give where condition?

string sql = "SELECT Files.file_name, Files.reference1, Files.rack_name, Files.wardrobe_name, Files.created_date, Documents.tag1, Documents.document_type, Documents.title,Documents.date FROM Documents CROSS JOIN Files where Documents.tag1='" + keyword + "' or Documents.tag2='" + keyword + "' or Documents.tag3='" + keyword + "' or Documents.tag4='" + keyword + "';";




Responses

Posted by: Ankitsrist on: 3/23/2013 [Member] Starter | Points: 25

Up
0
Down
hello,
we generaly use ON instead of Where clause in joins so u can use this query
string sql = "SELECT Files.file_name, Files.reference1, Files.rack_name, Files.wardrobe_name, Files.created_date, Documents.tag1, Documents.document_type, Documents.title,Documents.date FROM Documents CROSS JOIN Files ON Documents.tag1='" + keyword + "' or Documents.tag2='" + keyword + "' or Documents.tag3='" + keyword + "' or Documents.tag4='" + keyword + "';";



Chaithragm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response