Yeah, it worked!!!:
query = """SELECT *FROM db_alerts.alerts, db_app.trucks
WHERE db_app.trucks.customer_id = 1
AND db_alerts.alerts.truck_lic = db_app.trucks.lic
ORDER BY db_alerts.alerts.id DESC LIMIT 1"""
db_app.executesql(query)
Thanks Niphlod !!
Christian.
El lunes, 18 de febrero de 2013 13:34:01 UTC-3, Niphlod escribió:
>
> DAL can't do cross database queries, unless you use executesql.
>
> On Monday, February 18, 2013 5:27:38 PM UTC+1, Christian Espinoza wrote:
>>
>> Hi all, I'm need get the last alert(a table record) from db_alerts
>> database for every customer's truck,
>> but I'm can't get it, I'm using MYSQL.
>>
>> Table trucks at db_base:
>> db_app.define_table('trucks',
>> Field('customer_id', db_app.customers),
>> Field('lic', length=10),
>> Field('cap', 'integer'),
>> Field('vendor' db_app.vendor),
>> format='%(lic)s'
>> )
>>
>> Table alerts at db_alerts:
>> db_alerts.define_table('alerts',
>> Field('truck_lic', length=10),
>> Field('name', length=20),
>> Field('location', length=30),
>> Field('description', length=100),
>> Field('date', datetime)
>> )
>>
>>
>> WORKING MYSQL QUERY:
>>
>> SELECT *
>> FROM db_alerts.alerts, db_app.trucks
>> WHERE db_app.trucks.customer_id = 1
>> AND db_alerts.alerts.truck_lic = db_app.trucks.lic
>> ORDER BY db_alerts.alerts.id DESC LIMIT 1
>>
>> Using Dal
>>
>> query = (db_app.trucks.customer_id ==1) & (db <http://db.tracker.id/>_app
>> .trucks.lic == db_alerts.alerts.truck_lic)
>>
>>
>>
>> The second query is the problem, how can I run it??
>>
>> Thanks guys for your time and support.
>> Greetings.
>> Christian.
>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.