$result = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date<'$lastmsg' AND date BETWEEN $Yday AND $today ORDER by date DESC LIMIT 10");
Im getting 0 rows while there should be 1..
But my other query,
$result = mysql_query("SELECT * FROM users_msgs WHERE uID = '$USER' AND date > $today
AND date<'$lastmsg'
ORDER by ...
I am writing a web app which uses SQL as input. This SQL must always be a CREATE TABLE statement, and what my app needs to do is getting the following attributes from it:
Field name
Type
Length (if available)
Binary (if available)
Allow NULL (if available)
Auto increment (if available)
Example SQL:
CREATE TABLE customer
(First_Name ...
Hi Friends, I have the following queries and I want to put them in an sql CASE statement so I would have only one query but I don't know how to do that. Can somebody help me?
IF (SELECT EtlLoadId
FROM ssislogs.audit.processcontrol
WHERE SubjectArea = 'UaqaFacetsImp') > 0
SELECT pc.SrcFileName + ' - '+ CONVERT(VARCHAR(10), pc.[Reco...
I have a table in which i keep different meters (water meter, electricity meter) and in another table i keep the readings for each meter.
The table structure is like this :
The meter table
MeterID | MeterType | MeterName
The readings Table:
ReadingID | MeterID | Index | DateOfReading
The readings for a meter are read monthly. The t...
Run out of ideas... I need to group all entries form database. There are fields ID, NAME, CLASS, CREATED. Output would look like this:
<h2>3. Class</h2>
<div class="cont">
3rd class entries..
</div>
<h2>8. Class</h2>
<div class="cont">
8th class entries..
</div>
... and more
So if there are entries with class 3, they all go in the...
The way I want my stored procedure to work is this, the user passes all of the customer data, name, phone, and all of address info into the procedure, then I want to perform an insert into the address table, get the id generated from that insert, use that id in another insert for the customer table then return the customer id to the user...
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` varchar(15) NOT NULL,
UNIQUE KEY `id` (`id`,`name`),
CONSTRAINT `data_ibfk_1` FOREIGN KEY (`id`) REFERENCES `keywords` (`id`) ON DELETE CASCADE ON...
I can successfully connect to the database with my datacontext object. I am able to read and write to the database successfully, however I can't use the same syntax that others appear to be using.
For example, when I want data from a table, I have to do something like this:
db = new UserDataDataContext(WebConfigurationManager.Connecti...
I have two SQLite tables I want to compare. To set up the tables:
CREATE TABLE A (Value);
CREATE TABLE B (Value);
INSERT INTO A VALUES (1);
INSERT INTO A VALUES (1);
INSERT INTO B VALUES (2);
INSERT INTO B VALUES (1);
The closest I got with comparing two tables is using the SQL below:
SELECT 'A' AS Diff, *
FROM (SELECT * FROM A EXC...
Hello,
I'm dealing with sql and my sql is not as good as my ruby, so I hope you can help me out.
I have da table that looks like this:
messages:
id INTEGER PRIMARY KEY AUTO_INCREMENT
to VARCHAR(255)
text text
shown DATETIME
For now my script generates this part depending on the number of online players.
"to = 'STEAM_0:0:xxx' OR to =...
Hi,
I'm using oracle sql developer, or oracle sqlplus.
Thank,
Mattan
...
I'm adding SQLite support to a Rails 2.3 codebase designed for MySQL.
Most of the changes so far have been fairly straightforward, but I've now found some examples like the following code:
SomeModel.find(:first,
:conditions => ["? LIKE CONCAT(some_attribute, '%')", a_variable]
)
I can't just use the ANSI concatenation operator beca...
Ok, not sure if this is possible to do..
I have a query that returns just simple records from the database, but formatted out as XML as follows:
select name, address, dateCreated, flag
from table
where name = 'test'
for xml path('row'), root('rows')
ok, no problems, and I get the XML as desired:
<rows>
<row>
<name>jddjdjd</nam...
Hi everyone ,
Lets say I have a table called Employees , and each employee has a primarykey called (E_ID)
and I have another table called Positions , and each Position has a primarykey called (P_ID)
and I also have another table called offices , and each office has an ID called (O_ID)
Now I want to create a table that has three primaryK...
Hi, imagine I have this table called Department. Each Department can have child Departments.
I was thinking of having a column called ParentDepartmentID as foreign key to another department. If this key is null, it means it's a Parent top class department and not child of any other department.
I guess you could call this a self referen...
Greetings
i wana know how can i export data from a table to access through a sql job
i am using sql server 2008 and office 2007
...
Hello,
I have an Oracle table as shown below
Orders
---------
ORDERID
DESCRIPTION
TOTALVALUE
ORDERSTATUS
I have the below mentioned query
select ORDERID,ORDERSTATUS
FROM ORDERS
WHERE ORDERID IN( 1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1020,
1030,104,1040,1090,789)
Some orderIDs mentioned above are ...
Hi experts,
I am trying automatically increment the alpha numeric field (say for productid in product table).
But I am getting an error (see below).
Could somebody please look into this error or any other approach to achieve this task?
My table details:
create table tblProduct
(
id varchar(15)
)
create procedure spInsertInProduct
AS...
I have some entries in my database, in my case Videos with a rating and popularity and other factors. Of all these factors I calculate a likelihood factor or more to say a boost factor.
So I essentially have the fields ID and BOOST.The boost is calculated in a way that it turns out as an integer that represents the percentage of how oft...
I've read online for a while now that using indexes really speeds up your database queries.
My question is what are indexes? Why do they speed queries up?
...