1

Hi everyone I am having some problems with my SQLite database in my java program. I am trying to retrieve data from a couple of tables but it says my table doesn't exist. I have checked using DB Browser and it's definitely there, so I'm not sure what I'm doing wrong. This is the error I receive:

[SQLITE_ERROR] SQL error or missing database (no such table: staff_clocked_in.clock_in_time)

SELECT * FROM staff, staff_clocked_in.clock_in_time WHERE staff.staff_id = staff_clocked_in.staff_id;

I'm sure my tables exist and there is data in both tables, here is a screenshot of my db browser.

enter image description here

If it helps, this is how I have setup my tables:

STAFF:

CREATE TABLE IF NOT EXISTS staff (staff_id INTEGER PRIMARY KEY NOT NULL, first_name TEXT NOT NULL, last_name TEXT NOT NULL, job_title TEXT NOT NULL);

STAFF_CLOCKED_IN:

CREATE TABLE IF NOT EXISTS staff_clocked_in (staff_id INTEGER PRIMARY KEY NOT NULL REFERENCES staff(staff_id), clock_in_time DATETIME NOT NULL);

Can anyone see anything wrong with my query? I'm not good with databases so hopefully it's just something simple.

2
  • In your FROM staff_clocked_in.clock_in_time is not a table. It should be just staff_clocked_in Commented Apr 5, 2018 at 2:07
  • Thanks I managed to solve it using your advice. Commented Apr 5, 2018 at 2:33

1 Answer 1

2

The error message is correct staff_clocked_in.clock_in_time is not a table.

You should use staff_clocked_in instead which is your table.

So the fixed query should look like

SELECT * 
FROM staff, staff_clocked_in 
WHERE staff.staff_id = staff_clocked_in.staff_id;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.