Real SQL like problem ( 2 Views )

no kitty!
  1. Hi, I want to search the database by the first letter of company names. I can use the LIKE in my SQL query (LIKE 'A%' ) to get the result.

    But my question is how I can search those companies whose name started with numbers? I tried " (cmp_name_en LIKE '0%' OR LIKE '1%' OR LIKE '2%' OR LIKE '3%' OR LIKE '4%' OR LIKE '5%' OR LIKE '6%' OR LIKE '7%' OR LIKE '8%' OR LIKE '9%' )", but database reports errors. My database is Postgresql 7.4.1

    Desperately need your help, thank you!
    Ji Tao

    (İnanç Ataer , Saint Kitts and Nevis)

  2. Code:

    where substring(cmp_name from 1 for 1)
    between '0' and '9'

    You may have to change the substring syntax. As written is ANSI SQL but I donät know if that is supported by Postgres.

    (mehmet sipan, Bahrain)

  3. Thank you, I know what my problem is it is really stupid.
    It should be:
    cmp_name_en LIKE '0%' OR cmp_name_en LIKE '1%' OR cmp_name_en LIKE '2%' OR cmp_name_en LIKE '3%' OR cmp_name_en LIKE '4%' OR cmp_name_en LIKE '5%' OR cmp_name_en LIKE '6%' OR cmp_name_en LIKE '7%' OR cmp_name_en LIKE '8%' OR cmp_name_en LIKE '9%'

    The substring solution also works great in postgresql Thank you very much.

    (ferit, Netherlands Antilles)



Related Topics ... (or search in 1.720.883 topics !)

sql server management studio - problem creating sql file (10)
real estate management - sql restructuring question (12)
sql query to an oracle database, basic sql problem (2)
importing from sql to asp problem (lsitbox displaying problem) (2)
sisoft problem or real problem? (1)
sisoft problem or real problem? (1)
a hard problem for run sql, run sql on one server and table created on another server (1)
i need some help with a real life problem: (4)
problem with real producer plus 10 (1)




copyright © 2007-2031 Pfodere.COM ( 7 Pfoyihuee Online )

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
1.1746