Hi.
On Fri, Jun 15, 2001 at 02:13:27PM +0530, [EMAIL PROTECTED] wrote:
[...]
> update travel set nome_hotel=hotel.id where
> hotel.hotelname=travel.nome_hotel.
>
> It does not work. What would be the corret way?
>
> > SELECT t.id, h.hotelname from travel t, hotel h where t.nome_hotel =
> > h.hotelname;
>
> This will just display the rows. I need to update the travel table with
> the id of hotel table based on the hotel names being the same.
Just create a new table with the data and rename it afterwards:
CREATE TABLE travel_new
SELECT h.id
FROM travel t, hotel h
WHERE t.nome_hotel = h.hotelname;
you have to create (or specify) indexes seperately.
[...]
> > What I want to do is replace the nome_hotel field with the ids of the
> > hotel table for names that match the hotel.hotelname in the
> > travel.nome_hotel. How do I do this.
IMHO, the SELECT above, does something different. If I follow your
instructions word by word, I would expected the following SELECT to
work (not tested):
SELECT IFNULL(h.id, t.nome_hotel) AS nome_hotel
FROM travel t LEFT JOIN hotel h ON t.nome_hotel = h.hotelname
(of course, you have to rewrite that as CREATE to replace the original table)
Bye,
Benjamin.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php