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
LVL 7
gudii9Asked:
Who is Participating?
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
0
Garfield SamuelsProject ManagerCommented:
Could it be because you have quote marks around the  '100000'.  Maybe try without them ... population >= 100000
0
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';
0

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tim PalmerLevel 3 Support TechnicianCommented:
or alternatively use a LIKE

NAME LIKE '*USA*'
0
Ryan ChongCommented:
do some debugging and see what you getting?

select NAME from city
group by NAME
order by NAME

see if USA is listed there?
0
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

generic SELECT * FROM YOURTABLENAME

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 *
0
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)

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

above also gives wrong result
0
gudii9Author Commented:
SELECT *
FROM CITY
WHERE POPULATION > 100000 AND COUNTRYCODE = "USA";

it worked as aboe but it never said in description countrycode column name clearly?
0
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
SQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.