karimali831 Posted February 27, 2010 Share Posted February 27, 2010 Hi, E.g. $ergebnis = safe_query("SELECT status, ID, name FROM ".PREFIX."cup_all_clans WHERE ID= (from table cups)); How can I do this? Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 27, 2010 Share Posted February 27, 2010 You need a join query. Can you provide the field structure from both tables and we can provide an answer. Quote Link to comment Share on other sites More sharing options...
karimali831 Posted February 27, 2010 Author Share Posted February 27, 2010 Like this? First attatch is from cups table and second from cup_all_clans [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 27, 2010 Share Posted February 27, 2010 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"); Quote Link to comment Share on other sites More sharing options...
karimali831 Posted February 27, 2010 Author Share Posted February 27, 2010 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 any ideas? Quote Link to comment Share on other sites More sharing options...
karimali831 Posted February 27, 2010 Author Share Posted February 27, 2010 Is the query correct or is there something wrong on my side? Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 27, 2010 Share Posted February 27, 2010 Sorry, my faul. There should be a space after from Quote Link to comment Share on other sites More sharing options...
karimali831 Posted February 27, 2010 Author Share Posted February 27, 2010 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? Quote Link to comment Share on other sites More sharing options...
karimali831 Posted February 27, 2010 Author Share Posted February 27, 2010 anyone please ? Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 27, 2010 Share Posted February 27, 2010 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"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.