Dear, 
Solution for number 1, you can use inner join to join some tables, like this: 
1.table1 = t_comment, table2 = t_post 
select * from t_comment c 
inner join t_post p 
on c.id_post = p.id_post 
where p.judul like '%keyword%' or p.isi_post like '%keyword%' or 
c.email like '%jontri%' 

2.Of course, we can use OR in our statement if we want to select from more than 
two columns. Not only that, we also use AND. To use OR or AND and another OR, 
depend your requirement. 

thank's 
---------------------------------- 
Jontri Pakpahan 
http://jontriphan.co.nr 

----- Original Message ----- 
From: "Tedit kap" <[EMAIL PROTECTED]> 
To: "php mysql" <[email protected]> 
Sent: Monday, May 12, 2008 2:29:00 AM (GMT+0700) Asia/Bangkok 
Subject: Re: [php_mysql] basic search 







Thanks. Two more questions based on this: 
1) I have to select from eight similar tables (table1, table2 table3 etc..) 
like this. How do you select form that many table, what is the syntax? Do you 
repeat the whole select queary and use UNION eight times or how? I tried commas 
in the query but it didnt work. (table1, table2, table3) If there is a shortcut 
of writing instead of joining eight queries with UNION, is one way more 
efficient than the other? 
2) Can you use OR statement if you were to select from more than two columns? 
Such as article title, articlebody and additionalcolumn? If so how? Do you just 
place another OR so there are two ORs now? 

----- Original Message ---- 
From: Jontri Pakpahan < [EMAIL PROTECTED] > 
To: php mysql < [email protected] > 
Cc: php mysql < [email protected] > 
Sent: Sunday, May 11, 2008 6:25:02 AM 
Subject: Re: [php_mysql] basic search 

Please try to make like this: 
SELECT * FROM the_table WHERE articletitle LIKE '%keyword%' OR articlebody LIKE 
'%keyword%' 
------------ --------- --------- ---- 
Jontri Pakpahan 
http://jontriphan. co.nr 

Hi, 
I have a table like 
articleid-articleda te-articletitle- articlebody 
I am looking for a simple php script that will search my database which 
contains articles against keywords entered by the user...So, it should bring up 
that article that contains that keyword or words entered by the user. 

For example: 
select * from the_table where articletitle or articlebody contains keyword 
of course this is wrong syntax I guess but I just wrote this to explain what I 
want: search a certain keyword in article text body and bring the results.... 
What is the correct syntax? I could not see a "contains" or something like that 
when I searched.... 

____________ _________ _________ _________ _________ _________ _ 
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. Try it now. http://mobile. yahoo.com/ 
;_ylt=Ahu06i62sR 8HDtDypao8Wcj9tA cJ 

[Non-text portions of this message have been removed] 

[Non-text portions of this message have been removed] 

__________________________________________________________ 
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. Try it now. 
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

[Non-text portions of this message have been removed] 



[Non-text portions of this message have been removed]

Reply via email to