Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Can i output combined query to DBGrid or DBEhlibGrid (http://www.chiefdelphi.com/forums/showthread.php?t=57824)

i2ppl 07-06-2007 03:18

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

MattD 07-06-2007 15:43

Re: Can i output combined query to DBGrid or DBEhlibGrid
 
You can probably do a query such as this:
Code:

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.

Scott L. 07-06-2007 23:13

Re: Can i output combined query to DBGrid or DBEhlibGrid
 
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.:D


All times are GMT -5. The time now is 00:24.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi