Hello
This is a newbie question. I could successfully retrieve the results
by sending two queries and extracting data with Python, but I was
wondering if I could perform the same action in one SQLite query.
Here's an example of data in the CODE and COMPANIES tables:
========
CODE table
id=1
number=26
========
COMPANIES table
id=x
code=1
========
I'd like to check if there are actually as many rows in COMPANIES that
match whatever number of rows is saved CODE.number.
This works:
========
sql = 'SELECT id FROM code'
rows=list(cursor.execute(sql))
for id in rows:
sql = 'SELECT code.number,COUNT(companies.code) FROM code, companies
WHERE code.id="%s" AND companies.code="%s"' % (id[0],id[0])
result = list(cursor.execute(sql))
print "Code=%s, number=%s" % (id[0],result[0][0])
========
This doesn't:
========
SELECT code.number,COUNT(companies.code) FROM code,companies WHERE
code.id=companies.code
========
Can SQLite do what I'd like to do above, or should I just forget use
the two-step above?
Thank you for any tip.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users