James, > I'm new to the list, to mysql and to dynamic website programming. I'm not > new to programming, had my nose in Access97 for the last few years, off and > on. So I'm used to being coddled with sql and can't find a syntax that > works for this situation: > > (I'm using phpMyAdmin to work with the database and test the queries. The > server is remote.) > > 3 tables: Persons, QualityA, QualityB > > Table Persons contains integer foreign keys for the other two tables. > > I need a query that "for a certain Person in table Persons, returns > QualityA.Name and QualityB.Name. > > If I use: > SELECT A.Name, B.Name, P.ID > FROM Persons P, QualityA A, QualityB B > WHERE P.ID = thatGuy, P.A_ID = A.A_ID, P.B_ID = B.B_ID; > > I get strange results > > Name Name ID > "B Quality" "B Quality" thatGuy > > instead of > > Name Name ID > "A Quality" "B Quality" thatGuy > > To be specific, for the A.Name column of the results, I get the correct > value for the B.Name; for the B.Name column, I get the same value, but it > replaces the space char in the value with " " ?! > > I've tried many different combinations, but either get similar weird > results or error messages. > If I throw out the QualityB table, I can get it to work... > > SELECT A.Name, P.ID > FROM Persons P, QualityA A > WHERE P.ID = thatGuy, P.A_ID = A.A_ID; > > Name ID > "A Quality" thatGuy > > Note: I use e-mail on a different machine/platform than I use for the > dynamic website programming, so I'm writing from memory, using different > identifiers for this posting than the actual ones used in my database. > > I have limited time to work on this project and will greatly appreciate a > hand getting over this wall. I've searched for hours on the net, and tried > the IRC channels, but everything is written for one or two table queries.
Change the WHERE clause so that the three comparisons are joined in one logical expression/result: SELECT A.Name, B.Name, P.ID FROM Persons P, QualityA A, QualityB B WHERE P.ID = thatGuy AND P.A_ID = A.A_ID AND P.B_ID = B.B_ID; =dn --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php