473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Select * returns no data

I have a problem where if I issue a select * from against a database it
returns no data,

but if I select column from it returns the data.

Why would the * not be working as a wildcard?
Jul 23 '05 #1
3 2858
Hendry Taylor wrote:
I have a problem where if I issue a select * from against a database it
returns no data,

but if I select column from it returns the data.

Why would the * not be working as a wildcard?


That's certainly unexpected.

Questions:
- What version of MySQL are you using?
- What environment are you using to execute the query? e.g. mysql
command-line tool, MySQL Query Browser gui application, Java program,
Perl script, C++, Microsoft ODBC client...
- Does this behavior occur in other query environments? Try it in the
mysql command-line tool and see if you get the same strange result.

Regards,
Bill K.
Jul 23 '05 #2
I am using this query from a PHP script but I am also testing it from
the windows gui.

The mysql server runs on a sun sparc with solaris 10, the mysql version
is 4.1.12
php 5.0.4

one thing i forgot to mention is that it only occurs when i have a where
clause. if i do just a select * from tabel it works fine. The result of
my where clause is a single row, but i want all the columns.

My table definition looks as follows:

CREATE TABLE clients (
clientid tinyint(4) NOT NULL auto_increment,
name varchar(50) NOT NULL,
password varchar(50) NOT NULL,
email varchar(255) NOT NULL,
ref varchar(50) NOT NULL,
title varchar(255) NOT NULL,
PRIMARY KEY (clientid)
);

#
#
#

INSERT INTO clients VALUES( '1', 'admin', '43e9a4ab75570f5b',
'y***@email.com', '', 'admin');

my select statement is as follows:

select * from clients where name = 'admin' and password = PASSWORD('admin')

I am trying to match the password given in the web page to php to the
one store in mysql.
If i change the select to only select a single column it works, put the
* back and it no longer works.

I tried it via the mysql interactive tool on the sun box and it works.
Bill Karwin wrote:
Hendry Taylor wrote:
I have a problem where if I issue a select * from against a database it
returns no data,

but if I select column from it returns the data.

Why would the * not be working as a wildcard?

That's certainly unexpected.

Questions:
- What version of MySQL are you using?
- What environment are you using to execute the query? e.g. mysql
command-line tool, MySQL Query Browser gui application, Java program,
Perl script, C++, Microsoft ODBC client...
- Does this behavior occur in other query environments? Try it in the
mysql command-line tool and see if you get the same strange result.

Regards,
Bill K.

Jul 23 '05 #3
Hendry Taylor wrote:
select * from clients where name = 'admin' and password = PASSWORD('admin')

I am trying to match the password given in the web page to php to the
one store in mysql.
I would do this in the following way:

SELECT c.clientid, c.name, c.email, c.ref, c.title,
IF(c.password = PASSWORD(?), 1, 0) AS password_matches
FROM clients AS c
WHERE c.name = 'admin'

Then plug in the user's input in place of the ? above.
If i change the select to only select a single column it works, put the
* back and it no longer works.

I tried it via the mysql interactive tool on the sun box and it works.


I believe the PHP interface to MySQL uses the MySQL 4.0 client library,
which has a different encryption algorithm for the PASSWORD function in
MySQL 4.1.1 and later. See the note about PHP on this page:

http://dev.mysql.com/doc/mysql/en/old-client.html

This would not explain why the query works when you select one column
and doesn't work when you select all columns, though. Unless there's
some sort of query result caching going on. Have you tried the PHP
query with specifying all the columns explicitly, instead of using "*"?

By the way, the PASSWORD function is supposed to be used only by MySQL;
the docs recommend that we do not use it in our own applications, for
the compatibility reason above. Their recommendation is to use a
hashing function like MD5 when we want to store things like passwords
for web application. See the note under the PASSWORD docs on this page:

http://dev.mysql.com/doc/mysql/en/en...functions.html

I made this mistake too, in a project a couple of years ago. I used the
PASSWORD function for the user accounts in a Perl web application. But
that made it hard to upgrade to MySQL 4.1. So I changed the user
account creation and modification page to store the password as MD5() of
the user's password input, and then my password-checking expression in
the login page to:

IF(c.password = MD5(?) OR c.password = PASSWORD(?), 1, 0) AS
password_matches.

So over time, people will gradually convert their passwords to MD5
hashes as they update their passwords. Then the app can be upgraded to
MySQL 4.1 seamlessly.

Regards,
Bill K.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: D. Shifflett | last post by:
Hi all, I am trying to run a Python program on my Win XP box, that I brought over from a Linux box. Of course, on Linux it works fine, but not so on Win XP. The program has a button to cause a...
1
by: D. Shifflett | last post by:
Hi all, I am having trouble with a program that ran fine on Python 2.0 (#0, Mar 1 2001, 01:47:55) on linux2 but will not work on Python 2.3.2 (#1, Oct 8 2003, 17:33:47) on linux2
0
by: Tanamon | last post by:
Hello All, I am a MySQL newbie trying to write a query that selects file_name records possessing the highest numbered version for that unique file_name. I show sample data and two trial queries...
7
by: Sunny K | last post by:
Hi guys, whilst working on a project which I thought was nearly complete I have come across a problem which was some how over seen, which I am hoping one of you guys know how to resovle. ...
3
by: Earl Teigrob | last post by:
I am considering writing a Class that Selects, Adds, Updates and Deletes Nodes in an XML File but do not what to reinvent the wheel. (See XML file below) That data format would emulate records...
4
by: VK | last post by:
Hello, I have a dataset which has one datatable in it. The dt has over 3000 rows in it. Now I would like to get the rows where the StartDate is 15 Feb 2005, so I did the following: ...
2
by: alok | last post by:
Hi I have opened a serial port and then blocked on a select system call . but select returns even if no data is comming from other end. So when I read the buffer after select returns, I only...
3
by: Jeff | last post by:
hey ..NET 2.0 I have a datatable which consist of 3 columns (int, date, value). This DataTable have 3 rows, the values of the "date" ("date" column is of datetime datatype) column is:...
1
by: remya1000 | last post by:
I’m using VB.net 2003 application program. I am trying to do a select statement whereby I'm searching between 2 datetime values that are being stored as datetime. records are stored inside...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.