The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I've got three tables, all with different numbers of columns. They all have a column 'cidname' to relate the groups between tables, and 'name' to relate individuals between tables. I'm currently using three "SELECT * FROM tablename WHERE cidname = 'blah'" to get my data, and having to pick out elements from the different result sets. I've been looking at JOIN and UNION stuff, but can't find an example I understand.
Code:
table1 cidname = abcd cidname = abcd cidname = dontselectme name = Goober name = Noob name = GMNE data2 = blah123 data2 = blah321 data2 = 35215 table2 cidname = abcd cidname = abcd cidname = dontselectme name = Goober name = Noob name = GMNE dataa = blahz dataa = Foo dataa = 1 datab = blahy datab = Ret datab = 2 datac = blahx datac = Voo datac = 3 table3 cidname = abcd cidname = abcd cidname = dontselectme name = Goober name = Noob name = GMNE data = foo data = moo data = hngo3 Code:
cidname = abcd, name = Goober, data2 = blah123, dataa = blahz, datab = blahy, datac = blahx, data = foo cidname = abcd, name = Noob, data2 = blah321, dataa = Foo, datab = Ret, datac = Voo, data = moo |
#2
|
|||
|
|||
![]()
select a.*, b.*, c.* from table1 a join table2 b on a.cidname = b.cidname join table3 c on a.cidname = c.cidname;
This (I think the syntax is correct) will work. To separate out the results, do something like: select a.name first_name, a.data2 somedata .............. This will rename the columns returned for the purpose of displaying / using the data. |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|