Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Posts
    4

    Question Unanswered: Using LIKE in a SELECT statment

    i have this in SQL Server

    select * from sl_costo
    where '018183334455' like idciudad+'%'

    i want to do it in PostgreSQL, but i got this error:
    Error: ERROR: Unable to identify an operator '+' for types 'character varying' and '"unknown"'
    You will have to retype this query using an explicit cast

    How can i do it?

    thanks in advance.

  2. #2
    Join Date
    Apr 2003
    Location
    Tunisia
    Posts
    192

    cool

    the plus signe is not necessary !

    i have this in SQL Server

    select * from sl_costo
    where '018183334455' like 'idciudad%'

    018183334455' is a column name ? you have strange naming system !!!
    Last edited by karim2k; 09-27-03 at 04:50.
    Open up
    Take a look to my Blog http://www.rundom.com/karim2k

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    danielal2, in postgresql, the concatenation operator is the standard sql double pipes

    where '018183334455' like idciudad||'%'

    rudy
    http://r937.com/

  4. #4
    Join Date
    Apr 2003
    Location
    Tunisia
    Posts
    192

    works ...

    My example above works perfectly witouht pipes or superMario !!
    Open up
    Take a look to my Blog http://www.rundom.com/karim2k

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    karim2k, your solution may be syntactically okay, but it will not "work" i.e. produce the correct solution

    where '018183334455' like 'idciudad%' will always return 0 records

    rudy
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Apr 2003
    Location
    Tunisia
    Posts
    192

    Thumbs up ok

    More explanatiolns ?
    Open up
    Take a look to my Blog http://www.rundom.com/karim2k

  7. #7
    Join Date
    Sep 2003
    Location
    Germany
    Posts
    63
    Hi Karim,

    the two compared strings will never be the same, so r937 is right!

    You need to compare the string '018183334455' with the variable defined as idciudad||'%'.

    Greetings,
    Carsten

  8. #8
    Join Date
    Apr 2003
    Location
    Tunisia
    Posts
    192

    Thumbs up wow

    I was sleepin while seeing that thread, I tought that '000212121' was a row name what a shame
    Open up
    Take a look to my Blog http://www.rundom.com/karim2k

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •