How do I force Postgres to use a particular index?

How do I force Postgres to use an index when it would otherwise insist on doing a sequential scan?

How do I see active SQL Server connections?

I am using SQL Server 2008 Enterprise. I want to see any active SQL Server connections, and the related information of all the connections, like from which IP address, connect to which database or...

How to call a stored procedure from Java and JPA

I am writing a simple web application to call a stored procedure and retrieve some data. Its a very simple application, which interacts with client's database. We pass employee id and company id...

is it possible to explicity insert values in timestamp column of DB2

is it possible to explicity insert values in timestamp column of DB2? For example i have a date time value '2\11\2005 4:59:36 PM'. How to convert it to timestamp value in DB2? Thanks in advance

MySQL: Can't create table (errno: 150)

I am trying to import a .sql file and its failing on creating tables. Here's the query that fails: CREATE TABLE `data` ( `id` int(10) unsigned NOT NULL, `name` varchar(100) NOT NULL, `value`...

MSG 2714 There is an object already named

I'm using sql server 2008 management studio. Im trying to create two seemingly simple tables but continue getting this error at execution. I have tried changing the names of these tables to many...

Conversion failed when converting the nvarchar value '' to data type int

While this may sound like a beginner 101 problem I think it is a bit more complicated. I have two instances of SQL server, one is a log-shipped read/only standby copy of the master database that...

Upsert SQL query

I am looking for some advice how to optimize a couple of SQL stored procedures. With the 1st query I am doing insert, and with the 2nd one I am doing update, if the data exists. What I want to do...

Updating foreign keys while inserting into new table

I have table A(id). I need to create table B(id) add a foreign key to table A that references to B.id for every row in A, insert a row in B and update A.b_id with the newly inserted row in B Is...

Rename single column in SELECT * in SQL, select all but a column

here is what I'm trying to do- I have a table with lots of columns and want to create a view with one of the column reassigned based on certain combination of values in other columns, e.g. Name,...

Find All Rows With Null Value(s) in Any Column

I'm trying to create a query that will return all the rows that have a null value across all but 1 column. Some rows will have more than one null entry somewhere. There is one column I will want...

Linking Subdatasheets to Main Table

I have a main table and multiple other tables for which I want to link each one to a row of the main table. The main table "Data" consists of columns (Name, x, y) where "Name" is the primary key...

What is this operator <=> in MySQL?

I'm working on code written by a previous developer and in a query it says, WHERE p.name <=> NULL What does <=> mean in this query? Is it something equal to =? Or is it a syntax error? But it is...

Update table field 1 to field 2 where field 1 equals field 3

So I need something like this: UPDATE j3gll_komento_comments SET parent_id = ( SELECT j3gll_komento_comments.new_id ) WHERE parent_id in ( SELECT j3gll_komento_comments.id FROM...

Can't execute multi-statement SQL through PHP code

The SQL code used below works just fine if pasted in PHPMyAdmin. But once I use it in custom PHP code it throws an exception: You have an error in your SQL syntax; check the manual...

SQL Error: ORA-02315: incorrect number of arguments for default constructor

I'm trying to figure out why this is throwing back an error. this is my object type CREATE type address_typ as object ( street varchar2(60), city varchar2(19), pCode varchar2(9) ) ...

JIRA - SQL Find all Subtasks given a parent issue number

The main table on the jira database has no information about subtasks. I'm trying to find all subtasks from a given parent issue using the SQL and not the JIRA web interface. Where is this...

Error in MySQL when setting default value for DATE or DATETIME

I'm running MySql Server 5.7.11 and this sentence: updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00' is not working. Giving the error: ERROR 1067 (42000): Invalid default value for...

Update Meta Value for WordPress posts with SQL

I'm trying to update the meta value for all of my posts in a WordPress database that match a certain criteria. I have a table I created called update_with_false where each row "value" matches the...

how to select a list of 10,000 unique ids from dual in oracle SQL

So I can't create or edit tables (I'm a user with read only permission) and I want to look up 10,000 unique id's. I can't put them inside of an IN() statement because oracle limits over 1000...

Calculate the minimum value of a database in python with the min sql query

I have a database: my column-name is waarde and my tablename is tblWaarden. He doesn't print the minimum value but SELECT MIN (waarde) FROM tblWaarden Is there anyone that can help me? def...

MySQL Regexp on blob column

I am having problem with using MySQL's REGEXP operator with blob column. Clause: WHERE table.blobColumn REGEXP '"postalCode";s:[1-9]' won't return me single result, even I got thousands of...

Sql query to find users with same skills

I have three tables UserInfo (U-id,U-name) Skill(S-id,S-Name) and a bridge table between them (cause they have many to many relationship) 3. UserSkill(U-id,S-id) I want to write a query to find...

HackerRank Weather Observation Station 5

I would like to know why my code isnt working. This question has been asked before here:...

What is wrong with this code. Why can't I use SqlConnection?

I am 100% newbie to SQl and wanted to make a ConsoleApp with the use of database. I read some about it and tried. When I needed to make SqlConnection, my VS 2019 Preview showed me...

Oracle - Joining a inline table or table on the fly

I have a problem where a validation Code is stored in my table along with other data. Unfortunately the description is stored in a table where I dont have access to. I do know the...

How to order by, a json_object in mysql

I've a problem sorting a JSON_OBJECT: How can I sort the objects as they are in the JSON OBJECT?

connecting aws rds(postgres db) and sqs

i have a postgresql database in amazon rds,i want to send a message to aws sqs when there is a new record inserted in to the database tables, how can i do that??

Select Names of city starting and ending with vowels from STATION table

Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates. I tried to run this query but...

SQL Find max no of consecutive months over a period of last 12 Months excluding certain months

I am trying to write a query in sql where I need to find the max no. of consecutive months over a period of last 12 months excluding June and July. so for example I have an initial table as...