2

I keep getting an error when I try to add in a TOP 1 to my select statement. The SQL runs fine without the TOP 1 so it got me thinking that TOP is not supported in WEB SQL but I can't find any documentation online.

Has anyone successfully used TOP in their WEB SQL?

This Doesn't Work!

tx.executeSql('SELECT TOP 1 * FROM MyForms WHERE laganRef IS NOT NULL', [], trySend, errorHandler); 

But This Works!

tx.executeSql('SELECT * FROM MyForms WHERE laganRef IS NOT NULL', [], trySend, errorHandler); 

Any help would be much appreciated.

Steven

3 Answers3

5

I believe WEB SQL uses LIMIT instead of TOP. So this should work:

'SELECT * FROM MyForms WHERE laganRef IS NOT NULL LIMIT 0,1'

Jonathan
  • 1,833
  • 13
  • 15
0
tx.executeSql('SELECT * FROM MyForms WHERE laganRef IS NOT NULL LIMIT 1'
                                                           , [], trySend, errorHandler); 

try this...

The Hungry Dictator
  • 3,444
  • 5
  • 37
  • 53
0

LIMIT 0,1 worked fine for me.

SELECT COL1, COL2 FROM TABLE1 LIMIT 0,1;
Newton Sarker
  • 67
  • 2
  • 10