select where in a field there are two commas

1

I have a table in mysql with a field called coordenadas with more or less information like this:

  

-75.99699,4.0537896 // 1 comma
   -76.01502,4.085585,1390.0 // 2 commas
   -76.478325,3.9739854 // 1 comma
   -76.0716,4.1359963,1751.0 // 2 commas

I would like to be able to do a select where I only bring the records that have two (2) comas ", " How could I do it?

    
asked by Jorius 18.11.2016 в 20:35
source

3 answers

8

You can do something like:

SELECT * FROM ejemplo WHERE coordenadas LIKE '%,%,%';

    
answered by 18.11.2016 / 20:46
source
4

You can use the expression 'LIKE', which allows you to select records as you indicate, it would look like this:

SELECT
tabla.coordenadas
FROM
tabla
WHERE
tabla.cordenadas LIKE '%,%,%';

Where the% character means that it finds any number, then a comma, then again any number, then the second comma and any other number eventually.

    
answered by 18.11.2016 в 20:49
0

You could use Like:

Select * from tabla where campo like ['%,%,%'];
    
answered by 18.11.2016 в 20:53