Re: MySQL with php
| From: | Bsantos PHP | Date: | Wed, 25 Sep 2002 10:20:27 +0000 |
| Subject: | Re: MySQL with php | ||
| References: | 1 | Groups: | php.lang |
| Request: | Send a blank email to php-lang+get-391@lists.php.net to get a copy of this message | ||
bsantos on 2002/09/25:
You know Jan... there's a old sy here in Portugal: "It is a either a Bull or
a Cow"!!
Shure the script'll not work! You see: no name can be X and Y at same time.
You're querying to obtain a name which must be twice at same time and that
doesn't exist.
In my opinion, you should do as most people do.
1. Create separated fields for firstname and lastname in DB:
ALTER TABLE names ADD fisrtname varchar(128) not null;
ALTER TABLE names ADD lastname varchar(128) not null;
2. Construct the script to make it happend:
Here you can make thinks different ways, it's a so "your call doc!!!!"
Anyway, some tips:
mysql_query("SELECT firstname, lastname FROM names WHERE firstname ='peter'
AND lastname='pan'");
...
or something like that...
...
bsantos
"Jan" <supergrovers@hotmail.com> wrote in message
news:20020922165309.88998.qmail@pb1.pair.com...
> Hello
> i've a simple question i think ;)
> if i want to do a query with 2 keywords in a MySQL database, how do i
write
> it in my script?
>
> ie. I want to search for name=peter pan with the keywords "pan" and
> "peter"
>
> I thought it's like this:
> $query=SELECT ... FROM ... WHERE name LIKE '%pan%' AND LIKE '%peter%'
>
> but this isn't working :(
>
> hope somebody can help me out.
>
> thanks,
>
>
> Jan
>
>