Skip to content

Tag: sql

how join laravel tables to get non intersected data

in my Laravel app I have 3 tables : users, documents and type_documents, the user have multiple documents and document have one type_document I want select the types that are not used in documents table for the current user with eloquent I try with this, but it give me the used type_documents : I use Laravel …

SQL SELECT with an extra column with more than 1 value

I have a table with column_1, column_2, column_3, and select it by: What I want is to add an extra column ‘hour’, it would have 24 possible values from 0 to 23. The outcome is to have every row [column_1, column_2, column_3] repeated 24 times with all possible 24 values of the extra column hour: H…

Deleting records from particular TABLE – Oracle SQL

I have 1 table i.e. TABLE_1 which has 2 columns i.e. ROLL_NO, ID I have another 2 tables i.e. TABLE_2 with 3 columns ROLL_NO, LINE_NO, CODE and TABLE_3 with 2 columns i.e. NAME, ORIG_CODE My question is I need to delete the records from TABLE_1 using other 2 tables TABLE_2 and TABLE_3 in such a way that if an…

Select items only if they all meet the specific condition

I have two tables on a Oracle SQL DB. Article (id [PK]) File (id [PK], article_id [FK], insertion_date [DATETIME]). I want to select files from articles that are more than 15 days old without adding new files. For example, if post ID 1 has a file added 10 days ago and another 20 days ago, they should not be r…

funny characters in Sql String

I have a query string that works fine if tableStr is for example MSFT. However, if tableStr is BRK-B, the query fails. How do I get around this? Answer Per MySQL Documentation, “The identifier quote character is the backtick (`)”. This means that if your table name has special characters in it, yo…