Querying tables based on other column values

Posted by blcArmadillo on Stack Overflow See other posts from Stack Overflow or by blcArmadillo
Published on 2010-05-27T13:33:07Z Indexed on 2010/05/27 13:41 UTC
Read the original article Hit count: 346

Filed under:

Is there a way to query different databases based on the value of a column in the query?

Say for example you have the following columns:

  • id
  • part_id
  • attr_id
  • attr_value_ext
  • attr_value_int

You then run a query and if the attr_id is '1' is returns the attr_value_int column but if attr_id is greater than '1' it joins data from another table based on the attr_value_ext.

© Stack Overflow or respective owner

Related posts about sql