MySQL query

Discussion about everything. New games, 3d math, development tips...
Post Reply
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

MySQL query

Post by monkeycracks »

Could someone with knowledge on MySQL queries help me out?

I have a table in a database called Users. In Users I have a field called un. I want to retrieve the value of un as matched by input.

So something like :

SELECT un FROM users WHERE un = WhateverValueHere
?

Hope I was clear enough..
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Code: Select all

select users.un from users where users.un = 'value';
but that only gives you users.un, which you already know right?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
jrm
Posts: 111
Joined: Tue Dec 13, 2005 8:57 pm

Post by jrm »

If you do a "SELECT * FROM users WHERE un = WhateverValueHere" it will get all the rows for that record.

JRM
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

also, remember that if you don't quote and escape your values, a user could pass "1; delete * from users;" or something similar as WhateverValueHere.. which could be rather nasty.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Thanks for your help you guys. The user won't actually be allowed to enter custom queries, this is just me fooling around with my own database for learning purposes basically.
Post Reply