Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   SQL Statement help (http://www.greenguysboard.com/board/showthread.php?t=43983)

CelticTiger 2007-11-20 11:34 AM

SQL Statement help
 
I've been trying to delete some links from my database using the following statement:

DELETE FROM `links` WHERE (SELECT * FROM `links` WHERE `url` LIKE '%domain%')

but get the following error:

"Operand should contain 1 column(s)"

Can anyone tell me where I'm going wrong?

Thanks!

HowlingWulf 2007-11-20 03:06 PM

Why do you have SELECT in there?
Should be more like

DELETE FROM `links` WHERE `url` LIKE '%domain%';

CelticTiger 2007-11-20 03:42 PM

Yeah - tried that and was getting an error with that one too....so figured I needed a subquery.

Useless 2007-11-20 07:58 PM

Wouldn't the simplist solution be
delete from 'links' where 'url' = 'whatever'

CelticTiger 2007-11-20 08:30 PM

It would if it was just one url :) unfortunately there are about 1500 from one domain that I need to delete - plus many more domains will pop up I'm sure that will need the same treatment.

shunga 2007-11-21 06:59 AM

I would use this:

DELETE FROM links WHERE url LIKE '%domain%'

CelticTiger 2007-11-21 10:49 AM

I tried that before posting - no luck with it - which is why I tried using the subquery.

Does Sparky still frequent the board?

CelticTiger 2007-11-21 10:56 AM

I got it :)

shunga 2007-11-21 11:22 AM

Quote:

Originally Posted by CelticTiger (Post 375167)
I tried that before posting - no luck with it - which is why I tried using the subquery.

MySQL can be quite pedantic with quotation marks.

Glad you could find the solution.


All times are GMT -4. The time now is 11:28 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc