Jump to content

[SOLVED] using two fields with like


isaac_cm

Recommended Posts

"+" is arithmetic addition operator.

 

[pre]

  f1    |    f2    |

---------+------------+

  ham    |    x      |

  y    |    spam    |

  culpa  |    mea    |

[/pre]

 

  
SELECT * WHERE CONCAT(f1, f2) LIKE '%am%'

will return all 3, if that is the result you want.

 

Teng's version

SELECT * WHERE f1 LIKE '%am%' OR  f2 LIKE '%am%'

will return the first 2.

 

Depends on how you want it

hello fenway

I have my table like that

 

main(varchar)  sub(varchar)        result of using "+"

------------  ---------------    ------------------

  10                      Red                  10

  10                      Blue                  10

  12                      Green                12

  Red                      null                  0

  Blue                    null                    0

  White                  null                    0

 

 

as you see I get zeros !!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.