
May 15th, 2003, 02:46 PM
|
|
|
|
Join Date: Apr 2007
Location: Omaha, NE
Posts: 23
Time spent in forums: 13 sec
Reputation Power: 0
|
|
|
Error in MySQL SELECT UNION Statment
I have the following script on a page:
include("database_connection.php");
$stmt = "(SELECT * FROM tbl_a WHERE field_b != 'Other' ORDER BY field_b)";
$stmt .= " UNION (SELECT * FROM tbl_a WHERE field_b = 'Other')";
$rs = mysql_query($stmt) or die (mysql_error());
I have Apache/MySQL/PHP on two computers; each has the same versions. I can't figure out why this script works on one but the other says, "You have an error in your SQL syntax near '(SELECT * FROM tbl_a WHERE field_b != 'Other' ORDER BY field_b' at line 1"
I know I have an active database connection because I can get other pages to show data properly. I know the data is there because first, I dumped from the working computer, and second, I checked through MySQL monitor.
Anyone know what I'm doing wrong with my SQL statement?
Errrr...
|