Forum Moderators: coopster

Message Too Old, No Replies

2 Tables - 1 Statement - 1 Output - 1 Criteria

Select From Multiple Tables

         

sencee

8:35 pm on May 23, 2004 (gmt 0)

10+ Year Member



Hey,

Im stumped, i have tried everything and the nearest i can get is a ambiguity error message.

Basically, without pasting loads of code.

Page 1 get a ID to search for. This is sent to the next page in a function, lets call this function F1.

I want to display the contents of field ID, User of table Fault and field Status of table FaultAction, where ID = F1.

ID is the Pkey of both tables.

---Edit---


("SELECT FaultID, ReporterUsername, FaultType, Status
FROM fault, faultaction
WHERE $searchList = '".$frm_search."'
AND fault.FaultID = faultaction.FaultID")or
die(mysql_error());

Birdman

12:17 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe you get the ambiguity error when you select a field that has the same name in both tables. THe way to corredt it is to prefix the tablename to the field, just like you did in the WHERE clause.

("SELECT fault.FaultID,...)

Birdman

sencee

5:36 pm on May 24, 2004 (gmt 0)

10+ Year Member



anyway.. i have sorted that problem, but now i have another.

It combines the tables, but now it doesn't actually filter the search.

When u put say 31 in the search. It outputs all the records in the talbe (regardless whether they match the criteria or not) and also displays in the FaultID columm, 31 for every record.

coopster

9:27 pm on May 24, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Your
WHERE
clause may be giving you issues. You are asking your query to compare the form value to a variable, but we don't know what that variable is...


WHERE $searchList = '".$frm_search."'

You may want to have a look at the PHP Troubleshooting Tips in the PHP Forum Library [webmasterworld.com] for some troubleshooting concepts. Messages 1 and 3 [webmasterworld.com] may help you with your SQL issues.