Ria
Ria

Reputation: 467

mysql query: searching based on all values in column rather than one value in column

select address
from properties.tblpropertyassetclass_property_mapping  a
INNER JOIN properties.tblproperty b ON a.propertyid = b.propertyid
where propertyassetclassid =2;

This is the query that I have as of now. We can focus on this particular portion of the query and propertyassetclassid = 2. I would like to execute this query for all values in propertyassetclassid[there are 25 random values in this column]. Instead of ANDing each value like

   and propertyassetclassid = 4
   and propertyassetclassid = 5
   and propertyassetclassid = 6

I feel like there should be an easier way to do what I am trying to accomplish.

Upvotes: 0

Views: 36

Answers (2)

Mawia HL
Mawia HL

Reputation: 3665

This may work if the value begins from 1 and ends in 25:

select address
    from properties.tblpropertyassetclass_property_mapping  a
    INNER JOIN properties.tblproperty b ON a.propertyid = b.propertyid
    where propertyassetclassid BETWEEN '1' AND '25';

Upvotes: 0

Putra L Zendrato
Putra L Zendrato

Reputation: 332

As I know may be you want like this

select address
    from properties.tblpropertyassetclass_property_mapping  a
    INNER JOIN properties.tblproperty b ON a.propertyid = b.propertyid
    where propertyassetclassid is not null

Upvotes: 1

Related Questions