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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Statement ( Please Fix )

Author  Topic 

tdodnz
Starting Member

23 Posts

Posted - 2002-03-31 : 21:05:15
strSQL = "SELECT TOP 1 tblUsers.url FROM tblUsers WHERE tblUsers.Pops >= '5' AND tblUsers.ID <> "' & strID & '" ORDER BY tblUsers.Pops DESC"

theres my statement please tell me what is wrong with it, and change it for me please.

This is the error im getting
Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.


Thanks

tdodnz
Starting Member

23 Posts

Posted - 2002-03-31 : 21:08:02
I put in the wrong error this is what im getting.

Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'tblUsers.Pops >= '5' AND tblUsers.ID <>'.

Please Help


Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-03-31 : 21:23:06
If it's for access
try
strSQL = "SELECT TOP 1 tblUsers.url FROM tblUsers WHERE tblUsers.Pops >= ""5"" AND tblUsers.ID <> " & strID & " ORDER BY tblUsers.Pops DESC"

If creating a t-sql query then
strSQL = "SELECT TOP 1 tblUsers.url FROM tblUsers WHERE tblUsers.Pops >= '5' AND tblUsers.ID <> " & strID & " ORDER BY tblUsers.Pops DESC"

are you sure that tblUsers.Pops is a string?

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-03-31 : 21:24:49
If your SQL statement is coming out like your second post, it is an ASP problem. Your strID isn't a NULL is it ?
It looks like your statement is being truncated.

Also, if tblUsers.Pops is an integer, you don't need to surround the 5 with apostrophes.

Damian
Go to Top of Page
   

- Advertisement -