Select like (2 different parameters)

Asked

Viewed 9,931 times

0

I have a table with several cars, I need to get only the ones I need.

Example:
goal
fox
Parati
Kombi
Voyage

I want to catch only goal and Kombi.

I am using the following command to pick up where GOL value is in my table...

SELECT * FROM `volkswagen_base` WHERE link like '%gol%';

How do I pick up and display the goal and Kombi values?

  • 1

    But you do not need to use the LIKE. you can use the WHERE link = 'gol' AND or link = 'Kombi'

  • time my string is big like "asdasd/gol&123/dasjd"

  • 1

    Or if you use like, you can use WHERE link LIKE '%gol%' AND link LIKE '%Kombi%'

  • Try it this last way

  • thanks, it worked out

  • 1

    Okay, I posted the answer for you... If you can, give a OK

  • Check under the arrows ;)

  • Just to be clear @Charlesfay, even if the link string is large it can contain Gol and Kombi or just a two?

  • hello just out of curiosity the link is the column name?

Show 4 more comments

1 answer

5


You can elaborate your SQL this way:

SELECT * FROM volkswagen_base WHERE link LIKE '%gol%' OR link LIKE '%kombi%'
  • 1

    managed using the: SELECT * FROM volkswagen_base WHERE link LIKE '%gol%' OR link LIKE '%Kombi%' Thanks

  • So I asked you what value the link stored, the AND would not work, since you want records that are Kombi or Gol (either one of the two meets). Note that it is a good practice to put Likes among paranteses, like this: (LIKE '%gol%' OR link LIKE '%Kombi%'). This should be done because of the OR. AND has precedence over it and if you had another condition with AND in another field, then you may have problem if you don’t use the paranteses.

  • That’s right, that’s right @Cantoni

  • That was as simple as that.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.