Tag: mysql

SQL query, what Items are in a bucket?

I am trying to solve a problem similar to this one: I have a DB table like : ╔════╦═════════════╦═══════════╦════════╗ ║ ID ║ Bucket Name ║ Item Name ║ action ║ ╠════╬═════════════╬═══════════╬════════╣ ║ 1 ║ B_a ║ item1 ║ insert ║ ║ 2 ║ B_a ║ item2 ║ insert ║ ║ 3 ║ B_b ║ item1 […]

SQL: How to insert data in specific column with specific id as well

Is it possible to perform kind of that query on single table? I have read that it could be done by multiple tables (inserting in first table by selecting that specific value from second ) INSERT INTO Customers (CustomerName, Country) SELECT SupplierName, Country FROM Suppliers WHERE Country=’Germany’;

merge two SQL Tables with similar column names

i have two database tables: resultspassed with: id, name, device, passed and resultsfailed with: id, name, device, failed, aborted, notrun can I somehow merge these 2 tables with a select, so I’ll get the following ‘view’: id, name, device, passed, failed, aborted, notrun using ‘0’ as default values for the missing information. Unfortunately i cannot […]

How to avoid null date record where there is record with given date else need to get record with null date

I have table in which for same AgencyMaster ID I have multiple entry with different effectiveStart date and effectiveEnd date, and one entry with both effectiveEnd and effectiveStart as null. If I’m giving date which is doesn’t have entry then it should return record with effectiveEnd and effectiveStart as null else corresponding record with that […]

Save Html data in XML to sql using stored procedure

Here is the Xml data of table i am passing from front end to stored procedure. <ArrayOfUserData xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”> <UserData> <Name>Dovyan<Name /> <id>434556464<id /> </UserData> <UserData> <Name>Alex<Name /> <id>12345767<id /> </UserData> </ArrayOfUserData> This is the above xml i am passing to stored procedure as @in_params. Here is the stored procedure. USE [DATABASE] GO SET ANSI_NULLS […]

How to join two tables by using the first relevant date?

I would like to join to two tables using the date as the link, however, I do not want an exact match. The first table has more dates than the second one so I want the match to be dates from the second table to ‘closest’ date. Example Table 1: Date1 2016-06-01 2016-06-02 2016-06-03 2016-06-04 […]

SQL Server 2012 query date

How can I return values in a where clause for something like this: Get me all the records that exist in table1.de1,table2.de2,table3.de3,table4.de3 select * from table1 inner join table2 on table2.carID = table1.carID inner join table3 on table3.carID = table1.carID inner join table4 on table4.driverID = table1.driverID where a recietrecord exists in table2 and its […]

sql query to fetch the one value from table if we have same value saved twice

i need to find a record from a table and if record already exist than only one record will be shown (i cannot use DISTINCT) for example if there are 2 value in table www.google.com and another will be google.com/testing so my query should be like that it will get display only either of any […]

mssql to mysql query conversion

The below query works fine in mssql. I tried using information_schema instead of sys. But no luck in mysql. SELECT c.NAME AS property_name, t.NAME AS datatype FROM sys.columns c JOIN sys.objects o ON o.object_id = c.object_id JOIN sys.types t ON t.user_type_id = c.user_type_id JOIN sys.schemas s ON o.schema_id = s.schema_id WHERE s.NAME ='{0}’ AND o.NAME […]

How to differ MySQL and MS SQL database from code?

We have two database and single method. In our case queries for MySQL and Ms SQL db are different. We need to define when use query to needed db. How can I code in C# to find which db is using now?

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.