Sql Error What Should I Do?

jothis

Active Member
Licensed User
Hi All I Created A Simple Program For Inserting And Viewing Data

Please See The Program

My Problem Is When I Insert a person Without State And District It is Not Showing In the Table But It is In Database

I Know It Is Because Of The District And State fields are Empty In The Details table .
The State and District are Not Mandatory In My Program.

In this Case What Should I Do To Show That Record?
Can You Help Me?:sign0085:

Jothis
 

Attachments

  • SqlExp.zip
    6.8 KB · Views: 216
Last edited:

berndgoedecke

Active Member
Licensed User
Longtime User
Hello Jothis,
the State and District are not mandatory in your program but it is mandatory to hit the WHERE-condition. WHERE district.district_id=details.district_id AND state.state_id=details.state_id.

Best Regards

berndgoedecke
 

jothis

Active Member
Licensed User
Do You Mean I Must Hit State and Country? Is There Any Another Solution For Doing This?

Please Help Me

Jothis
:sign0085:
 

berndgoedecke

Active Member
Licensed User
Longtime User
Hello Jothis,
I don't know how to use three tables in a querry with join connections (SQLite provides (INNER[as standards]-, LEFT[OUTER]- and CROSS).
You can use two tables to build a LEFT JOIN querry, where details is your left table and state is the second. With LEFT JOIN you get all values from the left table but only the values from the Right table where the ON-statement is true.
FROM details LEFT JOIN state ON (details."state_id" = state."state_id")
Then you can build a VIEW or temp VIEW. This VIEW is the LEFT part of the next querry. You can connect the district to this View in the same way.
FROM tempview LEFT JOIN district ON (tempview."district_id" = district."district_id")

Its much complicated but it should show all details but ony state and district if it is used.

Best regards

berndgoedecke
 
Top