Page 1 of 1

Query with varchar and number

Posted: Wed Oct 31, 2007 12:28 am
by johnnymac131
Need to run this query i dont think it is written correctly

my code:

Code: Select all

$query = sprintf("SELECT * 
                     FROM article, journalist
                     WHERE article.journ_id = journalist.journ_id AND status = 'under consideration'");
Any ideas??

Posted: Wed Oct 31, 2007 4:23 am
by aceconcepts
If you use sprintf you should format the paramaters using a 'type specifier' according to the field data types.

Take a look at http://uk2.php.net/sprintf

Posted: Wed Oct 31, 2007 4:32 am
by CoderGoblin
On thing you might also want to consider is searching for an integer rather than text. Searching for text is slower than searching for integers and you run into all sorts of problems if you ever need to translate things. Also do you really need to use * or can you just return some applicable columns. Again it is just a speed thing.