Can i output combined query to DBGrid or DBEhlibGrid

Hello friends!
I need your help in this case.

I’ve 2 tables: table1(id, id_bookname) and table2(id, id_bookname, bookname).

table1’s id_bookname consists table2’s integer id_bookname's values.

Can i output combined query to DBGrid or DBEhlibGrid which contains table1’s id and table2’s bookname.

For instanse,

table1
id id_bookname

1 134
2 532
3 134
4 134
5 532

table2
id id_bookname bookname

1 134 book1
2 532 book2

Results in DBGrid must be:
id bookname

1 book1
2 book2
3 book1
4 book1
5 book2

You can probably do a query such as this:

SELECT table1.id,table2.bookname FROM table1,table2 WHERE table1.id_bookname=table2.id_bookname

I don’t know much about the DBGrid thing, though.

Are you Using SQL? Also are you trying to display the results in an ASP.Net Page using Visual Studios? or just in SQL, if using SQL.

If just in SQL the query by MattD should work.
If in ASP.Net using visual studios, under the data category drag the sql data source into the design view, hover the mouse over the new control and select the arrow in the upper right corner, select configure data source, create the connection string, then click next. Next select custom query, then paste MattD’s query into the feild. click next, finish
Next on the design veiw drag the gridveiw onto the screen where u placed the last control. select the configure datasource as you did for the previous control, select datasource1, or create new if not there. That should be it. to veiw results, click veiw in browser in the menubar on the top of the page.:smiley: