Beruflich Dokumente
Kultur Dokumente
SELECT userid, entryid, count(*) FROM ratingaction where userid=5649 and entryid
=106976;
SELECT userid, entryid, count(*) FROM ratingaction where userid in (SELECT id FR
OM users where campaignid=101) and entryid in (SELECT id FROM entries where camp
aignid=101) group by userid;
********************************************************************************
********************************************
group by changes the way results are displayed. Consider the following query:
SELECT userid, entryid, count(*) FROM ratingaction where userid in (SELECT id FR
OM users where campaignid=101) and entryid in (SELECT id FROM entries where
campaignid=101) group by userid, entryid;
userid
5648
5648
5648
5649
5649
5649
5649
5649
entryid
106894
106911
106975
106894
106911
106975
106976
106978
count(*)
1
1
1
1
3
1
1
1
Without
userid
5648
5649
entryid
entryid
106894
106894
in group by:
count(*)
3
7
********************************************************************************
********************************************
SELECTfoods.item_name,foods.item_unit,company.company_name,company.company_cityFROM
companyWHEREfoods.company_id= company.company_id;
http://www.w3resource.com/sql/joins/using-a-where-cluase-to-join-two-tables-rela
ted-by-a-single-column-primary-key-or-foriegn-key-pair.php#sthash.ao4YFjM4.dpuf
********************************************************************************
********************************************
How to have column in query result with values not from database?
select id, 0 from basics.
********************************************************************************
********************************************
How to find whether a column in database is empty?
NSString* query = @"select id, title, price from products";
//
// Assume that title and price are empty.
//
SQLiteResult* result = [SQLite query:query];
if ([result.errorCode isEqualToString:@"OK"])
{
int recordCount = [result.rows count];
NSArray* row = nil;
for (int index = 0; (index < recordCount); index++)
{
row = [result.rows objectAtIndex:index];
for (NSUInteger count = 0; (count < 3); count++)
{
if ([[row objectAtIndex:count] length] == 0)
{
NSLog(@"row with id %d has column %d as empty",
index, count);
}
}
}
}
********************************************************************************
********************************************
How to select 10 after 20th row?
select * from table limit 10 offset 20
********************************************************************************
********************************************
--> How to create a new table from existing table with columns reordered?
table1 columns: A, B, C, D. Create table by reversing the column order.
create table table2 as select D, C, B, A from table1
********************************************************************************
********************************************
SELECT id, english_content, french_content FROM basics_detail_list WHERE ((lower
(english_content_search) LIKE '%man%' or lower(french_content_search) LIKE '%man
%'))