MySQL help needed fast

  • Thread starter Thread starter epic
  • 15 comments
  • 437 views
Messages
2,223
United States
Miami
Everything is alright one day, than next time I go to check something blam! I haven't added anything for it to give me this error and I have no idea what to do. I don't want to start all over again either, I've added quite a lot of things to start from scratch again.



Database error in vBulletin 2.2.6:

Invalid SQL: SELECT userid,username
FROM user
WHERE userid<>
AND (usergroupid=5
OR usergroupid=6
OR usergroupid=7
OR usergroupid=2)
ORDER BY RAND()
LIMIT 1
mysql error: You have an error in your SQL syntax near 'AND (usergroupid=5
OR usergroupid=6
' at line 4

mysql error number: 1064
 
epic, I know you think the vB.com support forums are slow (although I have never had that problem), posting your question there will receive a much more informative and appropriate response.
 
Originally posted by epic


Invalid SQL: SELECT userid,username
FROM user
WHERE userid<>
AND (usergroupid=5
OR usergroupid=6
OR usergroupid=7
OR usergroupid=2)
ORDER BY RAND()
LIMIT 1
mysql error: You have an error in your SQL syntax near 'AND (usergroupid=5
OR usergroupid=6
' at line 4

mysql error number: 1064

You have no parameter here. It says "Where userid does not equal", and there's no condition.
 
Originally posted by GilesGuthrie
You have no parameter here. It says "Where userid does not equal", and there's no condition.


Any idea on how to fix that? I sure don't :(
 
Originally posted by Jordan
epic, I know you think the vB.com support forums are slow (although I have never had that problem), posting your question there will receive a much more informative and appropriate response.

I tried that. No luck yet, so I decided to try it over here.
 
Originally posted by epic



Any idea on how to fix that? I sure don't :(

OK, it's a logic problem.

What you WANT to say is:
WHERE userid <> 'villageidiot'

or something like that. The WHERE clause is a test, so you need to test for SOMETHING, whatever that may be.

Look at it this way:

A = 3
B = 2
Total = 5

If you want to report on all the instances where A + B = 5, you need to say this:

WHERE A + B = 5.

You see how this is a test?

So, in your example, let's say that you want to select the username for the fifth person to register. To do this, you would write:

WHERE userid = 5

Conversely then, if you want to select the username for anyone who was NOT the fifth person to register, you would write:

WHERE userid <> 5

Incidentally, it's better notation to use != in this example, because the exclamation point ! is taken to mean 'NOT', so you would write:

WHERE userid != 5

Hope that makes more sense.
 
Once you begin to get a handle on it, it is actually quite easy. You just need to spend a little time getting familiar with databases themselves first, before trying to teach yourself a database query language.
 
Originally posted by GilesGuthrie


OK, it's a logic problem.

What you WANT to say is:
WHERE userid <> 'villageidiot'

or something like that. The WHERE clause is a test, so you need to test for SOMETHING, whatever that may be.

Look at it this way:

A = 3
B = 2
Total = 5

If you want to report on all the instances where A + B = 5, you need to say this:

WHERE A + B = 5.

You see how this is a test?

So, in your example, let's say that you want to select the username for the fifth person to register. To do this, you would write:

WHERE userid = 5

Conversely then, if you want to select the username for anyone who was NOT the fifth person to register, you would write:

WHERE userid <> 5

Incidentally, it's better notation to use != in this example, because the exclamation point ! is taken to mean 'NOT', so you would write:

WHERE userid != 5

Hope that makes more sense.
You are now 1st on my list of computer geniouses.
 
I have the sudden urge to start screaming

GEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEKKK!!!!

GEEEEEEEEEEEEEEEEEEEEEEEEEEEKKKKK


But I was kinda into this stuff a little while ago, so then I'd be a hypocrit. :thumbsup:
 

Latest Posts

Back