Re: [sqlite] SQLite ordering data from multiple columns

2011-12-02 Thread Simon Slavin

On 2 Dec 2011, at 9:03am, Kit wrote:

> SELECT id, name FROM emp WHERE name LIKE '%emp%'
> UNION ALL
> SELECT id, descr FROM emp WHERE descr LIKE '%emp%';

I note very interesting names for the columns in this one.  The question I was 
asking was whether the second column was called 'name' for all rows returned by 
this query.

I also note an alternative to the above which might prove useful to the OP:

SELECT id, name, descr FROM emp WHERE (name || descr) LIKE '%emp%'

Or, if you want to be anal about it

SELECT id, name, descr FROM emp WHERE (name || 'xoxoxox' || descr) LIKE '%emp%'

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite ordering data from multiple columns

2011-12-02 Thread Kit
2011/12/2, colombus :
> I want to search this database I will search Emp Name & Emp Desc for example
> If Search EMP I will get results as EMP1 , this is EMP1, EMP2, this is EMP2.
> I need to order this search in such a way that I get the Emp Name Column
> first then I will get the Emp Desc Column. So the result should be as
> follows. EMP1, EMP2, this is EMP1, this is EMP2. Is it possible to implement
> this in one query in Sqlite ???

SELECT id, name FROM emp WHERE name LIKE '%emp%'
UNION ALL
SELECT id, descr FROM emp WHERE descr LIKE '%emp%';
-- 
Kit
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users