Discussion about everything. New games, 3d math, development tips...
monkeycracks
Posts: 1029 Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:
Post
by monkeycracks » Wed Jul 11, 2007 2:44 am
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 » Wed Jul 11, 2007 1:02 pm
Code: Select all
select users.un from users where users.un = 'value';
but that only gives you users.un, which you already know right?
jrm
Posts: 111 Joined: Tue Dec 13, 2005 8:57 pm
Post
by jrm » Wed Jul 11, 2007 2:12 pm
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 » Thu Jul 12, 2007 1:53 pm
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.
monkeycracks
Posts: 1029 Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:
Post
by monkeycracks » Sat Jul 14, 2007 4:28 am
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.