Sql Queries: Simple Vs. Complicated

liunx

Guest
Hello All<br /><br />I must say I am impressed with TCH. Very nice.<br /><br />I am using php/mysql. My question involves the sql query in my .php file receiving the info passed from html file. Now this query works<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$result = mysql_query ("SELECT column_1<br />              FROM table_1<br />              WHERE id LIKE '".$id."'");<!--c2--></div><!--ec2--><br /><br />This works fine. I pass an id of 1 and the correct table row prints. <br /><br />Now, if I am using multiple tables (see below)- I get error messages. Below is based off of what I am trying to do. I tried to replicate the code I am using as best I could- w/o actually revealing names of tables, etc. <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$result = mysql_query ("SELECT column 1, column 2, column 3<br />              FROM table 1, table 2, table 3<br />              WHERE id = '".$id.2"'<br />              AND id = '".$id.3."'<br />              AND id.3 = '".$1."'<br />              ORDER BY column 1");<!--c2--></div><!--ec2--><br /><br />Can PHP read spaces in table names?<!--content-->
It's generally a bad idea to have spaces in your tables names, but I believe it can be done by using back ticks (`) in the query.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$result = mysql_query ("SELECT `column 1`, `column 2`, `column 3`<br />??????鐕淩OM `table 1`, `table 2`, `table 3`<br />??????鐕盚ERE id = '".$id.2"'<br />??????鐕桸D id = '".$id.3."'<br />??????鐕桸D id.3 = '".$1."'<br />??????鐕≧DER BY `column 1`");<!--c2--></div><!--ec2--><br /><br />You could give that a try.<!--content-->
nice- thanks Mike J. I'll give that a shot and see what I can do.<!--content-->
 
Top