Hi. I'm having a problem on deleting a record using a function on SQL.
DELETE FROM tblServices GROUP BY ServiceID HAVING MID(ServiceID,1,2)='SG'

This query shows and error saying: Cannot group on fields selected with '*'.
I tried adding a specific field, like this:
DELETE ServiceID FROM tblServices GROUP BY ServiceID HAVING MID(ServiceID,1,2)='SG'
but it shows the same result.

Please help me.
Michael

try the following , may work for you.

DELETE ServiceID FROM tblServices 
where serviceid in (select ServiceID FROM tblServices GROUP BY ServiceID HAVING MID(ServiceID,1,2)='SG')

debasisdas,

That helps! I didn't know about that "IN", I should explore more on SQL. Thanks a lot!

Cheers,
Michael

good example for SQL query using IN, HAVING

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.