Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Counting or Deleting for Certain Value

Author  Topic 

battle59
Starting Member

8 Posts

Posted - 2007-04-05 : 11:31:05
Hi I am fairly new to this, and I searched the forums before posting this, but I couldn't find anything that applies. I was having trouble removing/counting for records that include a certain value.

Ex, I want to know how many records in the LASTNAME field have an @ anywhere in the field. I formerly used FoxPro and the way I could check was "Count for atc("@",LASTNAME)<>0".

I tried this sql query " SELECT COUNT(*) AS COUNT FROM `DATABASE` WHERE LOCATE(‘@’, LASTNAME)>0 " however, it didn't work. Can someone please help?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-05 : 11:36:10
[code]
select count(*)
from tables
where lastname like '%@%'
[/code]


KH

Go to Top of Page

battle59
Starting Member

8 Posts

Posted - 2007-04-05 : 11:46:46
That worked.

Thank you so much!!!

quote:
Originally posted by khtan


select count(*)
from tables
where lastname like '%@%'



KH



Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-05 : 23:58:43
One more method

select count(*)
from tables
where charindex('@',lastname)>0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -