SqlLite Help:How to get Data

blocks
How to get data from a column and row .I tried this but it is showing invalid statement

Welcome @Niya_Rose.
This message is the wrong command .
Check the names of your Fields: try removing the dot from the field name sl.no, change it to slno

Show your query.

What blocks do you use?

Which Sqlite component or extension do you use?

You don’t give us much information to help you.

In principle it’s like Rogerio says, you’re mistyping the query. See also the upper and lower case…

Iam using the inbuilt component


Image includes what i have done

:point_up:t2:
This

This is what i have done

Ys i have done but same error.

You need study Basic SQL.
Look your blocks
2 names tables diferents
What is the name of the table you created?

At the end of Select, remove the semicolon.

I want to show the bookname corresponding to the slno ,But iam not getting what i want

Screenshot from 2020-09-12 17-35-04

Did You create your table ?

@Rogerio_Rios Yes blocks

create table bookdata(slno int,bookname varchar(255))
Whenever i run this code App crashes

Change INT to Interger and and put an if not exist clause.
You need study SQLLITE.

1 Like

In the sentences the names do not go with single quotes?

I have this sentence in an app of mine:

CREATE TABLE IF NOT EXISTS JobControl ('id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'FechaEntrada' TEXT, 'HoraEntrada' TEXT, 'FechaSalida' TEXT, 'HoraSalida' TEXT, 'Descanso' NUM, 'Trabajado' TEXT, 'HorasDecimal' DECIMAL );

As you see in the sentence, the name of the field is put in simple quotes followed by the value type in capital letters…

Like says @Rogerio_Rios, Watch some tutorial about SQLite sentences

1 Like

Single or double … in the name of the table I use doubles and it works …
CREATE TABLE IF NOT EXISTS “tby” …

1 Like

Thanks to @Rogerio_Rios @pepocero For helping me.
CREATE TABLE IF NOT EXISTS bookdata ('slno' INTEGER, 'bookname' TEXT)
Again when I run this App crashes.Some Times It is working .I added AIA If you can Please help me!
example.aia (2.2 KB)

You have errors in the Sqlite sentence

When you create a table, your code is this:

CREATE TABLE IF NOT EXISTS bookdata ('slno' INTEGER, 'bookname' TEXT)

But you must end the sentence with a ;

CREATE TABLE IF NOT EXISTS bookdata ('slno' INTEGER, 'bookname' TEXT);

The same applies to the Get Data button. Your code is this:

select bookname from bookdata where slno=1

And this is wrong.
Use capital letters and end with a ;

SELECT bookname FROM bookdata WHERE slno=1;

Another point:
If you use the same button to create the table and to insert data you may have to press it twice to see the results.
I think it is more convenient to create the table when the screen starts or at another time than when you are going to enter data.


@pepocero
Whenever using this block app crashes,But Using this Block It works


You need to be less anxious. Observe the images. In an image you put the field names in quotes and put the field type as INT.

:point_down:t2: :point_down:t2: :point_down:t2:
CREATE TABLE IF NOT EXISTS bookdata (‘slno’ INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT , ‘bookname’ TEXT);

1 Like