You are here: Re: build WHERE clause on demand « PHP SQL « IT news, forums, messages
Re: build WHERE clause on demand

Posted by Hilarion on 11/14/05 17:27

> ...WHERE fruit IN ("apple", "pear");
>
> is what I was the syntax I was looking for. The way to built the
> "name1","name2" separated by comma on the fly was what I was trying to find
> out.
>
> I actually found a perfect solution using implode at php site:
> http://ca3.php.net/implode the solution by "adrian at foeder doe de" was
> just what I was looking for.


Do NOT use double-quotes to quote strings in SQL statements. It works in
some SQL engines but in most of them it's NOT the proper way. Use
single-quote instead, which is (or should be) valid in all SQL engines
because it comes from SQL standards. So like this:

....WHERE fruit IN ('apple', 'pear')


and NOT like this:

....WHERE fruit IN ("apple", "pear")


Also remember that this one:

....WHERE fruit IN ()

will NOT be accepted by most of SQL engines, so you'll have to
treat this case (when nothing was selected by user) differently.


Hilarion

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация