Web_dev_06 Posted April 5, 2007 Share Posted April 5, 2007 Hello everyone, I am not a SQL expert, and need help structuring a real complex query -at least to me- here are the details: - Table A contains usernames and ID's (the ID's is not unique, the primary key is a third column not important here) So, here is an example: A ------------------ username x y id 2 2 - Table B consists of many columns, but, the ones important here are: id and Data Name So, here is an example B -------------------- id 2 Data Name Test - Here is what I have: username (from table A) Data Name (from table B) (you might already know what is needed by now) - What I need: 1- ID of table A match the username 2- Query table (B) and query against the Data Name ==> Return the single row matching 1 & 2 am looking forward for your help. Quote Link to comment https://forums.phpfreaks.com/topic/45773-solved-complex-query-help/ Share on other sites More sharing options...
Wildbug Posted April 5, 2007 Share Posted April 5, 2007 SELECT A.id,B.data_name FROM A,B WHERE A.id=B.id AND username='...' AND data_name='...' It's not a complex query, just a complex description. :-) Actually you won't need to return the data name if you already know it in the WHERE clause. Was that what you're looking for? Quote Link to comment https://forums.phpfreaks.com/topic/45773-solved-complex-query-help/#findComment-222358 Share on other sites More sharing options...
Web_dev_06 Posted April 5, 2007 Author Share Posted April 5, 2007 Absolutely, Thanks so much. you are right, I made it complex, and here is the query used to solve the problem (very similar to yours- SELECT e.id, i.id FROM A e, B i WHERE e.DataName = 'Test' AND e.id = i.id LIMIT 0 , 50; Appreciate the fast response. Quote Link to comment https://forums.phpfreaks.com/topic/45773-solved-complex-query-help/#findComment-222377 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.