Clone Clone - 14 days ago 7
SQL Question

SQLlite3 - How do I target a specific value in SQL table?

I have a table

users
with two columns containing
user_names
with type
text
with a name and
points
with the type
real
. My goal is to select a specific value of an element in the first column called lets say
user4
and return the integer that is to the right of it.

My first thought was to use something that looks like this

select points from users where user_name like user4


Should this be accomplished some other way?

Answer

Sounds like all you're looking for here is validation. Your SQL statement as written will work fine if you simply add single quotes around user4. The only other thing I would change is to use = in place of like. The like keyword is typically only used when doing a wildcard matching which you are not doing in this case.

Comments