In Table, Time and date fields are two separate fields. I need to make a query something like this give all records where date and time <= givenDateTime. How do i do that please?
Here is the query in Oracle I was trying to remove the redundant math operation from:
SELECT name,
CASE
when nvl(num1,0) + nvl(num2,0) - nvl(num3,0) > 0
THEN nvl(num1,0) + nvl(num2,0) - nvl(num3,0)
ELSE 0
END
as result,
.... from ....
How do I not repeat the summation above?
Hey,
Lets say I have a table Y with column X.
There is one row of "X" with the string "abcdefg", and another row with "qwerty".
Can I make a SELECT query in sqlite to choose the row which contains the substring "abcd" ?
Thanks in advance.
hi,
I have an XML file which I'd like to query (read/write) in the same way as I would a relational database. Performance is not a big issue, I just want to be able to load the file and start querying, preferably without having to define a schema. Does anyone know if such software exists?
How to store results from following query into another table. Considering there is an appropriate table already created.
SELECT labels.label,shortabstracts.ShortAbstract,images.LinkToImage,types.Type
FROM ner.images,ner.labels,ner.shortabstracts,ner.types
WHERE
labels.Resource=images.Resource
AND labels.Resource=shortabstracts.Resource
AND labels.Resource=types.Resource;
i write this query using t-sql and give me an error (Incorrect syntax near the keyword 'OR')
How to write it in correct way ?
SELECT SUM(Quantity)
FROM Invoices
WHERE Invoices.InvoiceDocStatusID =
CASE @InventoryType
WHEN 1
THEN ((2)OR(1))
ELSE 2
END
I have to display the results of the below query as columns.
select to_char(sysdate + 1 - rownum,'MON-YYYY') as d
from all_objects
where trunc(sysdate + 1 - rownum,'MM') = trunc(to_date(:from_date,'MON-YYYY'),'MM')
minus
select to_char(sysdate + 1 - rownum,'MON-YYYY') as d
from all_objects
where trunc(sysdate + 1 - rownum,'MM') trunc(to_date(':to_date','MON-YYYY'),'MM')
Please help me in figuring that out.
I can't remember what the method is meant to be for ensuring the scope of a variable in a query is restricted to prevent mysql injection.
where should i put brackets in the following examples?
UPDATE table SET col_1 = '$var', col_2 = '$var2' WHERE col_1 = '$var3'
and
SELECT * FROM table WHERE WHERE col_1 >= '$var1'
(Obviously looking for answers not using PDO!)
I have two tables like Temp1 and Temp2
The Table Temp1 have id and Col1 fields and
The Table Temp2 have id and Col2 fields
I need to update the two table fields Col1 and Col2 using single query in SQL.
Can anyone help me??????
I have a simple query over a table, which returns results like the following:
id id_type id_ref
2702 5 31
2702 16 14
2702 17 3
2702 40 1
2702 26 4
And I would like to merge the results into a single row, for instance:
id concatenation
2702 5,16,17,40,26:31,14,3,1,4
Is there any way to do this within a trigger?
NB: I know I can use a cursor, but I would really prefer not to unless there is no better way.
I got a list of objects in the following query. How to delete items in the middle, saying I want to delete item in 2, 5, and 7 position? thanks
var archivedPwds = from archivedPwd in db.PasswordArchive
where archivedPwd.UserId == userId
orderby archivedPwd.DateChanged
select archivedPwd;
Query:
select emp.empname as Name, dep.depname as Department
from Employee as emp
inner join Department as dep on emp.depid=dep.depid
where emp.id='2'
How can I change this to linq to sql?
I know there is a limited version of a LIKE query in the App engine's datastore where you can only search on the end of a string but I can't seem to find the syntax.
I want to do something like this
SELECT *
FROM MyTable
WHERE name LIKE ji%
Is it possible to query for the SQL Server 2008 service startup parameter values using T-SQL? I'm specifically looking for the -g parameter that indicates how much memory that SQL Server will leave available for memory allocations within the SQL Server process, but outside the SQL Server memory pool [msdn reference].
Hi,
Is it possible to get the query result in .CSV file format from SQL SERVER 2000 and above versions?
If so can we use this feature from an asp.net application to get the result in CSV format?
If so how can we do this?
Hey guys,
i was wondering, can a parameter be used more then once in the same query, like this :
MySqlParameter oPar0 = new MySqlParameter("e164", MySqlDbType.String);
oPar0.Value = user.E164;
string sSQL0 = "Delete from callmone.call where (caller=?e164 or called=?e164);";
clsDatabase.ExecuteSQL(sSQL0, oPar0);
Is this possible or should i write 2 parameters?
I have following code :
try {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("ids", year);
return this.template.getJdbcOperations().query(
"SELECT * FROM INCOME WHERE PROVNUM=? AND FISCALDATE IN ( :ids )", this.rowMapper, parameters);
}catch (EmptyResultDataAccessException ex) {
return null;
}
But i am not able to send the value for PROVNUM. how to do that?
need help,
thanks.
If I have a linq query that creates the anonymous type below:
select new
{
lf.id,
lf.name,
lf.desc,
plf.childId
};
Is it possible to assign a specific type to one of the members? Specifically I would like to make lf.id a null-able int rather than an int...
In SQL, can we always write an inner join statement as a main query and subquery?
For example,
select * from gifts g where g.giftID in (select giftID from sentGifts);
can do a join and show the gifts sent in the sentGifts table, but it won't be able to show the sentTime because that is inside the subquery?
I'm working with PreparedStatement with MySQL server.
example:
String myQuery = "select id from user where name = ?";
PreparedStatement stmt = sqlConnection.prepareStatement(myQuery);
stmt.setString(1, "test");
stmt.executeQUery();
ResultSet rs = stmt.getResultSet();
How can I receive the full SQL query that is about to be executed on the MySQL server?
thanks!
Hi, I inserted some error record to my table, I can query via the sql below and found hundards of record marked with half.
SELECT * FROM `marathon`
WHERE gender = 'male' && distance = 'half';
How to write a SQL then I can modify the result rows distance from 'half' to 'full'.
Thank you.
I have a table with an 'expires' datetime column. I want to find all the items that have an 'expires' date earlier than now.
I've tried
session.query(Item).filter(Item.expires < now())
but it doesn't return anything regardless of the dates in the table.
I'm using PostgreSQL 8.4.
How do I do this comparison?
I notice my query doesn't behave correctly if one of the like variables is empty:
SELECT name
FROM employee
WHERE name LIKE '%a%'
AND color LIKE '%A%'
AND city LIKE '%b%'
AND country LIKE '%B%'
AND sport LIKE '%c%'
AND hobby LIKE '%C%'
Now when a and A are not empty it works but when a, A and c are not empty the c part is not excuted so it seems?
How can I fix this?