V. Prince V. Prince - 2 years ago 53
SQL Question

Mixing data from mysql in the same table using - PHP

Good Morning Guys...

this is my tblRecords from mysql.

ID ---- Name ---- Remark1 ---- Remark2
1 Dead ok -
1 Dead - ok

when i call the data from tblRecords i want to display the output like this

ID ---- Name ---- Remark1 ---- Remark2
1 Dead ok ok

Please help i'm just a newbie in programming..

Thanks in advance..

Answer Source

If you mean the character - itself, then the query may look like the following:

SELECT r1.ID, r1.Name, r1.Remark1, r2.Remark2
FROM tblRecords r1
JOIN tblRecords r2 USING(ID)
WHERE r1.Remark1 != '-' AND r2.Remark2 != '-';

Here we join the table with itself by ID, then collect "non-dash" Remark1 records from the first table, and Remark2 records from the second.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download