Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

researching in multiple fields with php / mysql

New Here ,
Jul 22, 2008 Jul 22, 2008
Good morning to all,

I am trying to define an instruction SQL (in Dreamweaver / PHP / MySql) that returns me results done through a research form. The typed word should be researched in several fields of a table and to return me with results.

Here two SQL that I did, but in both results comes empty.

----------------

SELECT *
FROM produtos
WHERE prod_modelo AND prod_funcao AND prod_descricao AND prod_tags LIKE %colname%
ORDER BY prod_modelo ASC


--------------------------

SELECT *
FROM produtos
WHERE prod_modelo LIKE %colname% AND prod_funcao LIKE %colname% AND prod_descricao LIKE % colname% AND prod_tags LIKE %colname%
ORDER BY prod_modelo ASC


------------------------

In this link, you can see the recordset print screen. recordset image
TOPICS
Server side applications
588
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 22, 2008 Jul 22, 2008
Luis Godinho Ramos wrote:
> SELECT *
> FROM produtos
> WHERE prod_modelo LIKE %colname% AND prod_funcao LIKE %colname% AND
> prod_descricao LIKE % colname% AND prod_tags LIKE %colname%
> ORDER BY prod_modelo ASC

The second example you give is closer, but you need to enclose the query
fields in quotes and use OR rather than AND...

SELECT * FROM produtos WHERE prod_modelo LIKE '%colname%' OR prod_funcao
LIKE '%colname%' OR prod_descricao LIKE '%colname%' OR prod_tags LIKE
'%colname%' ORDER BY prod_modelo ASC


HTH,

Pete.
--
Peter Connolly
http://www.kpdirection.com
Utah


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 21, 2010 Feb 21, 2010
LATEST

I just did this, and DW (CS4) removed all the single quotes that were surrounding the %colname% after saving the query.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines