Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: MySQL

by screamingeagle (Curate)
on Jul 18, 2002 at 22:50 UTC ( #183074=note: print w/ replies, xml ) Need Help??


in reply to Filtering MySQL results

you're enclosing the column names and the table names in single quotes. try removing them ...and add the where clause like stajich suggested :

$sth = $dbh->prepare("SELECT username,password,group FROM users where +group = 'Admin'"); $sth->execute;
In SQL Server, the check is not case-sensitive, however , if you're using oracle, you might want to write the SQL Stmt like this :
SELECT username,password,group FROM users where upper(group) = upper('admin')
hth...


Comment on Re: MySQL
Select or Download Code
Re: Re: MySQL
by thor (Priest) on Jul 19, 2002 at 11:58 UTC
    screamingeagle wrote:

    In SQL Server, the check is not case-sensitive, however , if you're using oracle, you might want to write the SQL Stmt like this :

    SELECT username,password,group FROM users where upper(group) = upper('admin')
    The problem with this is that unless the database engine is very advanced, this will table scan instead of using an index. The reason is that it needs to run a function on one of your columns, and the optimizer has no idea what the result of that function call will be before hand. So, it needs to calculate it for every row when you do your query.

    You are in luck, however, in that there are alternative solutions to the problem. One is to create a rule on the column that only allows certain known values. The second is to have the upper in your insert statement, thus canonicalizing the values in the column. I'm sure there are more, but this should get you started.

    thor

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://183074]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2014-09-18 01:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (103 votes), past polls