# selecting by attributes

12 replies to this topic

### #1 Cartogirl Posted 25 November 2008 - 10:47 AM

Cartogirl

Contributor

• Validated Member
• 19 posts
• Gender:Female

I have two files that I want only to pull certain data from. I need to find the slope % that is equal to 0.5 degrees and greater in an area that is <=-49 and >=-65. When I use the following equation I end up with everything being selected. I know this is incorrect as I can clearly see that the area covered by the slope points is less than that of the Bathy Depth.

I have tried many different ways and still am not comming up with the correct statement. If I relate the tables will that work? If so how do I then select only the data that I need?
Any suggestions would be great.

Cheers

Robyn

"Depth" <= -49 OR "Depth" >= -65 AND "slope" >= .5

### #2 Robert2009 Posted 25 November 2008 - 10:59 AM

Robert2009

Master Contributor

• Validated Member
• 125 posts
• Gender:Male
• Interests:reading newspaper, Netflix, weather, travel
• United States

I have two files that I want only to pull certain data from. I need to find the slope % that is equal to 0.5 degrees and greater in an area that is <=-49 and >=-65. When I use the following equation I end up with everything being selected. I know this is incorrect as I can clearly see that the area covered by the slope points is less than that of the Bathy Depth.

I have tried many different ways and still am not comming up with the correct statement. If I relate the tables will that work? If so how do I then select only the data that I need?
Any suggestions would be great.

Cheers

Robyn

"Depth" <= -49 OR "Depth" >= -65 AND "slope" >= .5

Have you tried this way Depth" <= -49 OR "Depth" >= -65 OR "slope" >= .5 ? Change from AND to OR after 65 ?

### #3 François Goulet Posted 25 November 2008 - 11:10 AM

François Goulet

Ultimate Contributor

• Validated Member
• 694 posts
• Gender:Male
• Location:Mille-Isles, Qc
• Interests:Cartography, History, Graphic Design and almost everything else...

I'm not an SQL expert, but I'd try to query them "separately".

"AND" has a precedence over the OR so you should applied you "AND" criteria over each Depth. It should be something like:

("Depth" <= -49 AND "slope" >= .5) OR ("Depth" >= -65 AND "slope" >= .5)

### #4 Cartogirl Posted 25 November 2008 - 11:33 AM

Cartogirl

Contributor

• Validated Member
• 19 posts
• Gender:Female

Thanks for the suggestions. The selection is still incorrect as all slope data was selected. I wonder if it is the files I am using that is causing the issues, would it be better to go back to the original joined bathy and slope files?
How do relates work? I know that they are good for this kind of situation where more than one field is needed ,so if I related them how would I then select from the two tables?

Thanks again

Cheers

Robyn

### #5 François Goulet Posted 25 November 2008 - 11:37 AM

François Goulet

Ultimate Contributor

• Validated Member
• 694 posts
• Gender:Male
• Location:Mille-Isles, Qc
• Interests:Cartography, History, Graphic Design and almost everything else...

You could always make your selection in each file and then intersecting the results...

### #6 Hans van der Maarel Posted 25 November 2008 - 12:07 PM

Hans van der Maarel

CartoTalk Editor-in-Chief

• 4,180 posts
• Gender:Male
• Location:The Netherlands
• Interests:Cartography, GIS, history, popular science, music.
• Netherlands

Assuming you mean "Depth between -49 and -65 and slope greater than .5":

`("Depth" <= -49 AND "Depth" >= -65) AND "slope" >= .5`

Hans van der Maarel - Cartotalk Editor
Red Geographics

### #7 Cartogirl Posted 25 November 2008 - 12:36 PM

Cartogirl

Contributor

• Validated Member
• 19 posts
• Gender:Female

I used the intersect tool and it seems to have selected the data needed. This was after trying each of the above statements. I am still not certain why none of them worked as they would generate all the data as selected, which again makes me think I did something incorrect when creating the new shape files that were then being looked at.

I now need to clip the point file with the classification area file and seem to only be generating a point file back.

Thanks for all the help.

Cheers

### #8 frax Posted 25 November 2008 - 03:38 PM

frax

Hall of Fame

• 2,420 posts
• Gender:Male
• Location:Stockholm, Sweden
• Interests:music, hiking, friends, nature, photography, traveling. and maps!
• Sweden

Is this ArcGIS? Aren't you supposed to write the fields like [depth] and not quoted? The query builder in ArcGIS is quite ok, and usually works for me if I am not sure.
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/

### #9 josie Posted 26 November 2008 - 07:43 AM

josie

Master Contributor

• Validated Member
• 120 posts
• Gender:Female
• Location:Netherlands
• Netherlands

Assuming 'depth' and 'slope' are fields:

Try

'depth' <=-49
AND 'depth >=-65
AND 'slope' = 0.5

### #10 josie Posted 26 November 2008 - 07:47 AM

josie

Master Contributor

• Validated Member
• 120 posts
• Gender:Female
• Location:Netherlands
• Netherlands

Just noticed Hans already suggested that actually. He is correct, it should work!

### #11 frax Posted 27 November 2008 - 02:48 AM

frax

Hall of Fame

• 2,420 posts
• Gender:Male
• Location:Stockholm, Sweden
• Interests:music, hiking, friends, nature, photography, traveling. and maps!
• Sweden

Also - if it is ArcGIS - then I think you can do it in a (visual) multi-step process - do one select, and reselect out of that selection.
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/

### #12 dsl Posted 01 December 2008 - 02:13 AM

dsl

Master Contributor

• Validated Member
• 225 posts
• Gender:Male
• Location:Denver
• United States

Is this ArcGIS? Aren't you supposed to write the fields like [depth] and not quoted? The query builder in ArcGIS is quite ok, and usually works for me if I am not sure.

Brackets are for geodatabases and quotes are for shapefiles if memory serves.

Cheers,
David

### #13 Cartogirl Posted 01 December 2008 - 11:53 AM

Cartogirl

Contributor

• Validated Member
• 19 posts
• Gender:Female

Thanks to all the help and advice on solving this problem.
Things are moving along now and it was because of all your ideas and suggestions.

Cheers

Robyn

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->