Difference between numbers and letters

Hello, In a database I put a kind of code(column1) and a category(column2). When the query is
select * where column1 and column2 = ‘white’
I recieve as answer the records where a code excists in column1 wich are matching with white.
Odd is that it shows only codes wich starts with 0-9 and not starts with A-Z although they are white too.
How can I avoid this?

regards

if you want to select something from columm1 and from a specific category(columm2)

then the query should be
[php]
$query = “SELECT * FROM table_name WHERE columm1 like ‘white’ AND columm2 = ‘categoryID’”;
[/php]

yeah I know.

I just assumed to be CategoryID but its columm2 and whatever name or property he assigned to that

I’m sorry, it must be
SELECT * FROM table_name WHERE column1 AND column2 is ‘white’
data in column1 shows up when it starts with a number, not when it starts with a letter.

im not sure if i understand what you want to do.

if you want to select value that starts with a number from a column:
[php]
$query = "SELECT * FROM table_name WHERE column_name REGEXP ‘^[0-9]’;
[/php]

just make it more complex according to your need. using AND or OR in your sql.

Look, in column1 contains number/letter combinations like 477FFE or 3542PO or it is empty,
column2 contains a category f.i. category white or red or black.
With the query
SELECT * FROM table_name where column1 AND column2 = ‘white’
wil show all records where column1 has a value belonging to category white
only when they start with combinations like mentioned above, starting with numbers
Not combinations like AC26756 or DG6722, starting with letters.

Or another example: simple database with one column called Code. It has 5 records withe letter/number combinations f.i
453RF9
39810A
78ERT6
E46y78
H786TY
Query SELECT * FROM table_name WHERE Code
shows the first three not the last two because they are beginning with a letter

it should show them all. In your database settings check the format of that column. It should be varchar if you want to use it like that.

Sponsor our Newsletter | Privacy Policy | Terms of Service