[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PHPwestoz] [OT] Relational SQL Databases



Nicolas Connault wrote:

--snip--


This one is easy: "SELECT Songs.* FROM Songs, Albums, Artists WHERE
Songs.AlbumID = Album.ID AND Album.ArtistID = Artist.ID AND
Artist.Artist LIKE 'A%' "

I would rename the Artist.Artist field to Artist.Name if I was you,
it's never good to name a field by the same name as the table.

More helpful?

Very Nice.

Does anybody know of a way to do an INSERT that 'fails' silently if the
entry is already there?
I can just do a select and then an INSERT if the entry isn't there. I
already do a similar thing with SELECT and then INSERT or UPDATE
depending on the result.

Tim

p.s.

> I then want to do a 'INSERT INTO Artists SET Name=$artist'
That's not the right syntax. It should be "INSERT INTO Artists
(`Name`) VALUES ('$artist')"  Check the syntax for these statements in
the MySQL doc.

I was just reading the manual and I believe this is an alternative format. I normally use the one you showed. I haven't checked if the other one work but will as I like the syntax a little better.

--
Tim White - Use the Fox, Luke!
PGP/GPG id: 602E944D, Pub Key Serv: subkeys.pgp.net
Fingerprint: 04C2 9682 B7B2 3006 009D  A9F3 067E EDCD 602E 944D
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!
--

Attachment: signature.asc
Description: OpenPGP digital signature