PDA

View Full Version : SQL error


june_c21
11-11-2007, 10:51 PM
Hi, i can't figure out what's wrong with this code. it returned zero result

SELECT id, month, start_date, end_date, user.name, report.staff_no,details,amount,gl_code,user.bank,user.acc_no,status FROM user,report WHERE report.staff_no = user.staff_no

ngaisteve1
11-12-2007, 08:33 AM
Do you get zero result also when you copy this query and run it in query analyzer?

scoutt
11-13-2007, 08:55 AM
Look at that query closely. You have some of the field names with there table names but others don't have then.

SELECT id, month, start_date, end_date, user.name, report.staff_no,details,amount,gl_code,user.bank,user.acc_no,status FROM user,report WHERE report.staff_no = user.staff_no

Once you start doing that (bold) you have to do it to all of them, not just a couple. I don't believe that is the problem but it is a start.

afterburn
11-15-2007, 01:49 PM
in mySQL that may be true but not in MS-SQL, Oracle etc. They require unambiguous column names, you may have to use an alais.

scoutt
11-19-2007, 08:20 AM
yes in mysql you also have to have unambiguous column names but I don't think it can be mismatched like that. Like I said, it may not be the problem but worth a start anyway. But I guess we will never know the answer as the psoter has gone awry