Evolution #3366
Prefix Database tables columns names with table name ?
Start date:
11/27/2013
Due date:
% Done:
0%
Estimated time:
Bdc:
Description
Example¶
Table User: -Id -Name etc.
Would become
Table User: -UserId -UserName etc.
Why?¶
While doing join query requests, when querying fields with the same name in different tables, we need to put aliases
If i do : "SELECT User.id, Image.id FROM User INNER JOIN Image" i won't be able to get the fields back. (Cursor.get("User.id") crash => can't prefix with table name)
Recurrences
History
#1
Updated by Mickael G. about 7 years ago
use alias...
you can use :- column ("id")
- table.column ("user.id")
- alias ("user_id")
- SELECT user.id as user_id FROM user
#5
Updated by Gregg C. almost 7 years ago
Using aliases can be really messy, as in AskNChat : https://git.tactfactory.com/ask-n-chat/ask-n-chat-android/blob/master/src/com/tactfactory/asknchat/provider/DiscussionProviderAdapter.java