Wednesday 15 February 2012

mysql - Trying to use stored procedure to access three tables but receiving only one row -


So far, I have tried several different methods of accessing data on three tables using the one stored procedure First I tried a simple selection statement:

  Select the Process Report Code () Start number. Where the verified data is verified number from serial_name, numowner.lName, numowner.fName, numowner.email, location.long, location.lat, number number, owner, location. Yoga = true and numbers ID = num.wner.Numbers_id and numbers.id = location.Numbers_id; End $$   

(Name has been changed to save the culprit)

  Select numbers Serial_number, numOwner.lName, numOwner.fName, numowner.email, location.long, location.lat, number Number verified, owned, location where number Used = true and number Id = num.wner.Numbers_id and number Id = location.Numbers_id;   

In phpmyadmin sql tab records gives both records. Then I tried a temporary table:

  to create the process report code () started using the temporary table_a_command (select number of serial_number, numowner.lName, numowner FName, numowner.email, location.long, Location.lat, Numbers.dateValidated by number, owner, location where number, sum = true and number id = num.wner.Numbers_id and number id = location.Numbers_id); Choose from the number used; End $ 1   

returns 1 out of 2 records as a process, but both records in the console. Finally I tried to join my table:

  create a manufacturing process report () Create unnecessary number while using the temporary table (Select number: Cyrill_number, numOwner.lName, numowner Include numbers in validity numbers from .fName, numowner.email, location number, number.lit, number.date, num.ind = num.wner.Numbers_id, add numOwner.Numbers_id = location.Numbers_id where numbers.use = truth); Choose from the number used; End $ $   

The same results as above will show both test records running only on SQL, if there is a loss in the form of IAC, but running the process with the exact same code is only one product Thank you

In your query, there is not a valid table selected against numowners, so what is wrong? You have tried to run your SQL in the query window in phpMyAdmin That ensure the return to the same query 2 lines?

I think the "owner" table should be "numowner", so I rewrote the stored procedure call below, besides, I'm not sure what kind of values ​​you have to store in the numbers I think that you are using a tinet (1), so I have changed it, as well. I hope it helps.

  DELIMITER $$ USE `db` $$ is present if report 'report' report '$$ process' codes () select n.serial_numb, o.lName, o.fName, o Include number n INNER from .email, l.long, l.lat, n.dateValidated number, numowner o ON.id at = o.Numbers_id INNER Join the place n.id = l.Numbers_id; Where n.used = 1 END $$ DELIMITER;    

No comments:

Post a Comment