Reputation: 66945
I want to create a DB table and a set of commands for it. So currently I have
this->command_create_files_table = "CREATE TABLE IF NOT EXISTS files (encoded_url varchar(300) UNIQUE NOT NULL primary key, file_name varchar(150) NOT NULL, user_name varchar(65) NOT NULL, is_public BOOLEAN NOT NULL, modified DATETIME NOT NULL default CURRENT_TIMESTAMP )";
this->command_create_file = "INSERT INTO files (encoded_url, file_name, user_name, is_public ) VALUES (:encoded_url, :file_name, :user_name, :is_public)";
this->command_update_file = " UPDATE files SET encoded_url=:new_encoded_url, file_name=:new_file_name, is_public=:is_public, modified=CURRENT_TIMESTAMP WHERE encoded_url=:encoded_url";
this->command_delete_file = "DELETE FROM files WHERE encoded_url=:encoded_url";
this->command_find_file = "SELECT file_name, user_name, is_public, modified FROM files WHERE encoded_url=:encoded_url";
this->command_find_all_user_files = "SELECT encoded_url, file_name, user_name, is_public, modified FROM files WHERE user_name=:user_name";
(using sqlite3pp syntax here)
I wonder how to SELECT
some predefined :N
(25 for example - no more) files or less from some start DATETIME
point (CURRENT_TIMESTAMP
for example)?
Upvotes: 0
Views: 1016
Reputation: 179
SELECT
fields_you_want_to_select
FROM
filesTbl
WHERE
DATETIME > start_of_range AND
DATETIME < end_of_range
LIMIT limit_num
Upvotes: 2
Reputation: 20462
SELECT
fields_you_want_to_select
FROM
filesTbl
WHERE
DATETIME > start_of_range AND
DATETIME < end_of_range
LIMIT
25
Upvotes: 1