I have table visitors and table users. Each visitor can be created by only one user and contains field visitors.userId. So, any another user from table users can edit or delete one or more visitors. …
Tag: sql
Dynamically name a column based on a WHERE condition
Objective: I am running a query on a weekly basis and would like one of my column to return the ISO_WEEK number with the prefix ‘W’. For example: W1. More specifically, I would like to reproduce the …
SQL : select the oldest record for each distinct element
I apologize for the poor worded title, let me illustrate first Here is the table : select task_id, task_status, date_change, username from logs order by task_id, date_change Results : TASK_ID …
columns in SQL Server
I have a sample table below: Flight Airport Datetime 123 AID_X_YZ 5/5/2018 12:52:00 AM 123 AID_X_YZ–> NRT_X 5/6/2018 5:50:00 AM 123 NRT_X …
Postgres SQL select query syntax
I have this SQL statement, I am getting a syntax error: SELECT * FROM user_table INNER JOIN ( klass_table LEFT JOIN room_table ) Syntax error is vague, it says: You have an error …
How to send SQL queries to a computer outside of the network through port?
I have a java program that uses SQL queries. The goal is to send them from my home PC to a workstation on a different network elsewhere. The SQL server is on Windows Server and I opened port 1433 for …
SQL query to fetch unique entries. Is the query correct and efficient?
The table structure is provided below. query used, desc p2p Output ‘auto_id’,’bigint(20)’,’NO’,’PRI’,NULL,’auto_increment’ ‘created_at’,’datetime’,’NO’,”,NULL,” ‘expiry_date’,’datetime…
Passing a column name as parameter to a stored procedure in mySQL
I’m creating some stored procedures to manage my DB. In particular, i want to create a stored procedore to edit a column, of a specific row, but i want to do it dinamically, passing the column name as an argument. That’s what i want to do Using the parameter keyi find the specific row in myTableth…
#1241 – Operand should contain 1 column(s) In wamp on phpmyadmin
Nested query in Sql. SELECT *, (SELECT `supplier_sign_up_id`, ( SELECT email_address FROM supplier_sign_up WHERE …
DO while based on query result
I got a block of the code written in PHP it uses a DB connection to an Oracle DB, i need to run a query on a data and the result for the first query it should be an input of the next query and this …