Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MySql query no result

When I do the query

select * from departments where dept_name = 'Finance';

I got the following result

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

why no results?

But I do the query

select * from departments;

I got the result

It does exist

the table departments is created by following:

CREATE TABLE departments (
    dept_no     CHAR(4)         NOT NULL,
    dept_name   VARCHAR(40)     NOT NULL,
    CONSTRAINT pk_departments PRIMARY KEY (dept_no)
);

The version of my MySql is 8.0.28 for Win64 on x86_64 (MySQL Community Server – GPL)

Any idea?

>Solution :

I think there are some spaces in your Finance value, you can check it out by using CHAR_LENGTH():

SELECT
CHAR_LENGTH(dept_name) AS 'character length' 
FROM departments 
WHERE dept_no = 'd002'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading