query issue

query issue

select * from city where population >= '100000' and NAME='USA';

why above query is not resulting any results while trying on ms sql server

please advise
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tim PalmerLevel 3 Support TechnicianCommented:
Have you tried using table.column format

eg: select table.* from table.city where table.population >= 100000 and table.NAME='USA';

Obviously table is the name of your table
Garfield SamuelsProject ManagerCommented:
Could it be because you have quote marks around the  '100000'.  Maybe try without them ... population >= 100000
Scott PletcherSenior DBACommented:
It's unlikely that the city "NAME" is USA.  (Since it's the "city" table, I would expect the "NAME" column to be the *city* name.)

Maybe something like:

select * from city where population >= '100000' and countryNAME='USA';

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Tim PalmerLevel 3 Support TechnicianCommented:
or alternatively use a LIKE

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
do some debugging and see what you getting?

select NAME from city
group by NAME
order by NAME

see if USA is listed there?
Mark WillsTopic AdvisorCommented:
City would normally be an attribute of location / address.

Double check the table name

Then look inside the table to see column values


check column names and values for the columns you want to use especially 'population' and 'name'.

then reform your query using the knowledge gleaned from above, building up, step by step, until you get your full requirement

1) select * from city
2) select * from city where population >= '100000'
3) select * from city where population >= '100000' and country = 'USA'

Each step, put in appropriate names and values found in the select *
Luan JubicaProject ManagerCommented:
Obviously, the values are filtering too much or are wrong..
Please post the structure of the table and some sample data. (Maybe only doing that you may find where your problem is)

gudii9Author Commented:
select * from city where population >= '100000' and countryNAME='USA';

above also gives wrong result
gudii9Author Commented:

it worked as aboe but it never said in description countrycode column name clearly?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.