Re: [sqlite] Newbie what does & do.

2009-03-28 Thread Dermot
2009/3/28 Jay A. Kreibich <j...@kreibi.ch>:
> On Fri, Mar 27, 2009 at 05:37:49PM +0000, Dermot scratched on the wall:
>
>> The statement is:
>>
>> SELECT COUNT(*) FROM products WHERE productid=808800033 AND
>> (allowcountry2 & 0x0001)
>> SELECT COUNT(*) FROM products WHERE productid=808800033 AND
>> (allowcountry1 & 0x8000)
>>
>> I believe the allowcountry part is a bit pattern lookup but I can't
>> find a definition for the & and so I am not sure what the statement
>> does bar count the results.
>
>  To actually answer your question, yes, "&" in SQLite and some other
>  DBs is a bitwise "and" operator, just like the C/C++ "&" operator.
>  "|" is a bitwise "or".
>
>  It is my understanding that these operators are not part of the
>  SQL standard, but a number of databases implement the operator.

First off, sorry it was such an off-topic question. Thank you Jay for
the answer.

I can't find any reference to the ampersand's usage in my new book, my
copy of learning MySQL or the SQLite Syntax documentation. I would
have expected symbols to be listed before A in the index myself. There
are references to bitmap indices. Symbols refer to the BNF notation
but without reference to &. I have posted to SQLQueries.  Hopefully I
can get an understanding of what that statement means from there.

Again sorry for the post.
Dp.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Newbie what does & do.

2009-03-27 Thread Dermot
Hi,

I just bough my "Introduction to SQL 4th edition" as per a list
member's advice.

Before I had a chance to take it home and start going through it I
came across an SQL statement that I could use some help understanding.

The statement is:

SELECT COUNT(*) FROM products WHERE productid=808800033 AND
(allowcountry2 & 0x0001)
SELECT COUNT(*) FROM products WHERE productid=808800033 AND
(allowcountry1 & 0x8000)

I believe the allowcountry part is a bit pattern lookup but I can't
find a definition for the & and so I am not sure what the statement
does bar count the results.

Can someone enlighten me? I should point out that this command is used
on a MySQL DB.

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


[sqlite] Newbie: Further reading / books recommendations

2009-03-18 Thread Dermot
Hi,

I need get up to speed on a number of aspect of databases. I do need
to grasp SQL syntax but also I also could use a more ideas on schema
design and the process of modelling.

I have learning MySQL. Are there books that the list might suggest?
Thanx,
Dp.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Newbie question

2009-03-18 Thread Dermot
2009/3/18 Hoover, Jeffrey :
>
> Assumming  this is only one row in tbl2 where name='Joe'...
>
> this should work:
> SELECT * FROM tbl1
> WHERE description='someval'
> AND foreign_key_id=(select id from tbl2 where name='Joe');
>
> this is better:
> select tbl1.* from tbl1, tbl2
> where tbl1.description='someval'
> AND tbl2.name='Joe' and tbl2.id=tbl1. foreign_key_id;
>
> if there may be many rows in tbl2 where name =- 'Joe' then
> SELECT * FROM tbl1
> WHERE description='someval'
> AND foreign_key_id in (select id from tbl2 where name='Joe');

Both of the top 2 worked. Thank you. I'll try and stick to the less
ambiguous form and bear in mind all the comments about single quotes.

A bit more information though. Is there a term for that type of SELECT
statement?

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


Re: [sqlite] Newbie question

2009-03-18 Thread Dermot
2009/3/18 Igor Tandetnik <itandet...@mvps.org>:
> Dermot <paik...@googlemail.com> wrote:
>> I want to do a select query a bit like this:
>>
>> SELECT * FROM tbl1 WHERE description="someval" AND
>> foreign_key_id=(select id from tbl2 where name="Joe");
>>
>> This gives me a syntax error and my other efforts are not yielding
>> results.
>
> What's the text of the error message?




SELECT * FROM tbl1 WHERE description="someval" AND
foreign_key_id=(select id from tbl2 where name="Joe");

This attempt give the error:

SQL error: near "=": syntax error

SELECT * FROM tbl1 WHERE description="someval" AND
foreign_key_id='select id from tbl2 where name="Joe"';

This return nothing, although it should. If I break the queries into 2
separate select statements they verify.

This is SQLite 3.5.1.

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


[sqlite] Newbie question

2009-03-18 Thread Dermot
Hi,

I am very green with SQL entirely so I apologise in advance for what
might be a simple query.

I want to do a select query a bit like this:

SELECT * FROM tbl1 WHERE description="someval" AND
foreign_key_id=(select id from tbl2 where name="Joe");

This gives me a syntax error and my other efforts are not yielding results.

I am not sure what the term is for such as statement, compound perhaps?

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