Jump to content

1 query, 2 selects?


karimali831

Recommended Posts

Ok so there will be a particular id you are looking up and need fields from both tables.

 

so if the id you are looking up is in $lookupid

 

$ergebnis = safe_query("select ca.status, ca.ID, ca.name  from".PREFIX."cup_all_clans ca,cups c WHERE ca.ID = c.ID and c.ID=$lookupid");

Link to comment
https://forums.phpfreaks.com/topic/193572-1-query-2-selects/#findComment-1019013
Share on other sites

Thanks for that but I get an SQL error.

 

$ergebnis = safe_query("select ca.status, ca.ID, ca.name  from".PREFIX."cup_all_clans ca,cups c WHERE ca.ID = c.ID and c.ID=$cupID");

 

and error:

 

# errorno=1064
# error=You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ca,cups c WHERE ca.ID = c.ID and c.ID=4' at line 1
# query=select ca.status, ca.ID, ca.name fromficocup_cup_all_clans ca,cups c WHERE ca.ID = c.ID and c.ID=4

 

It reads the correct ID from the correct table :D

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/193572-1-query-2-selects/#findComment-1019014
Share on other sites

Now how didn't I spot that.. ok but now this:

 

error=Table 'ficomedi_ficomedia.cups' doesn't exist

 

It should be ficomedia_cups, reading prefix twice?

 

I remove PREFIX and I get

 

error=Table 'ficomedi_ficomedia.cup_all_clans' doesn't exist

 

I don't understand how it reads the prefix twice, followed by a dot?

Link to comment
https://forums.phpfreaks.com/topic/193572-1-query-2-selects/#findComment-1019033
Share on other sites

you do need your ficocup_  prefix on your table names either as your define, or hardcoded

 

$ergebnis = safe_query("select ca.status, ca.ID, ca.name  from".PREFIX."cup_all_clans ca,".PREFIX."cups c WHERE ca.ID = c.ID and c.ID=$cupID");

or

 

$ergebnis = safe_query("select ca.status, ca.ID, ca.name  from ficocup_cup_all_clans ca,ficocup_cups c WHERE ca.ID = c.ID and c.ID=$cupID");

Link to comment
https://forums.phpfreaks.com/topic/193572-1-query-2-selects/#findComment-1019045
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.