Query with varchar and number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johnnymac131
Forum Newbie
Posts: 11
Joined: Sun Oct 28, 2007 11:51 am

Query with varchar and number

Post 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??
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post 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
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply