Connecting Tech Pros Worldwide Forums | Help | Site Map

Use one select query for two different table

Newbie
 
Join Date: Mar 2008
Posts: 4
#1: Jul 16 '08
hi,
I am working in asp.net with sqlserver2005. i am stored car information in one table an image for that car in other table. i can also stored that image id with respective car. I want to show some car information with it photo in datagrid.
But how can i select that both table in on single query

Please guide me.

Thanks
Schetan

idsanjeev's Avatar
Familiar Sight
 
Join Date: Oct 2007
Location:
Posts: 241
#2: Jul 16 '08

re: Use one select query for two different table


Hi
if you able to display the data selected in sql query then the select statement is
Expand|Select|Wrap|Line Numbers
  1. select a.fieldname1,a.fieldname2,a.fieldname3,b.fieldname1,b.fieldname2,b.fieldname3 from table1 a,table2 where a.fieldname1=b.filedname2
  2.  
in where clause one filed data is common in both table for jointing them
Regards
jha
vikas251074's Avatar
Familiar Sight
 
Join Date: Dec 2007
Location: Patna
Posts: 198
#3: Jul 17 '08

re: Use one select query for two different table


Quote:

Originally Posted by idsanjeev

Hi
if you able to display the data selected in sql query then the select statement is

Expand|Select|Wrap|Line Numbers
  1. select a.fieldname1,a.fieldname2,a.fieldname3,b.fieldname1,b.fieldname2,b.fieldname3 from table1 a,table2 where a.fieldname1=b.filedname2
  2.  
in where clause one filed data is common in both table for jointing them
Regards
jha


I am sure this will not work because image will not display this way. There could be another method.

Thanks and regards,
Vikas
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#4: Jul 18 '08

re: Use one select query for two different table


Quote:

Originally Posted by vikas251074

I am sure this will not work because image will not display this way. There could be another method.

Thanks and regards,
Vikas

Idsanjeev's solution is correct. He did not address the question of displaying the photo, just how to query both tables with a single query.

Jared
Reply