I've written a piece of SQL that works at the MySQL prompt, but doesn't work as expected through php.
MySQL version 5.0.95
mysql> SELECT ->
a.date, -> a.author,
-> a.comment, -> b.first AS
p_first, -> b.last AS
p_last, -> c.first AS
a_first, -> c.last AS
a_last -> FROM ->
pilot_activity a, -> person
b, -> person c ->
WHERE -> b.id =
a.pilot_id -> AND c.id =
a.author -> ORDER BY
-> p_last ASC ->
;+---------------------+--------+-----------------------------+---------+-----------+---------+-----------+|
date
| author |
comment
| p_first | p_last | a_first | a_last
|+---------------------+--------+-----------------------------+---------+-----------+---------+-----------+|
2010-03-21 10:02:06 | 50 | OPERATIONAL
PROCEDURES.... | Phill | Glasson |
John | Wilkinson || 2013-08-12 00:00:00
| 50 | 1
1
| John | Wilkinson | John | Wilkinson
|+---------------------+--------+-----------------------------+---------+-----------+---------+-----------+2
rows in set (0.00 sec)
But the PHP script, using the same query
$sql = <<<SQLSELECT a.date,
a.author, a.comment, b.first AS p_first,
b.last AS p_last, c.first AS a_first, c.last AS
a_lastFROM pilot_activity a, person b, person
cWHERE b.id = a.pilot_id AND c.id = a.authorORDER
BY p_last ASCSQL;
returns three rows!
<br>Phill Glasson<br>2010-03-21 10:02:06 OPERATIONAL PROCEDURES.... (John
Wilkinson)<br>
<br>Phill Glasson<br>2010-03-21 10:02:06 OPERATIONAL PROCEDURES.... (John
Wilkinson)<br>
<br>John Wilkinson<br>2013-08-12 00:00:00 1 1 (John Wilkinson)<br>