What's the difference between the two? They seem to have the same functionality at first glance.
Which one has faster performance which one is easier to use?
what is the purpose of a temporary table like in this statement? how is it different than a regular table?
CREATE TEMPORARY TABLE tmptable
SELECT A.* FROM batchinfo_2009 AS A, calibration_2009 AS B
WHERE A.reporttime LIKE '%2010%'
AND A.rowid = B.rowid;
Hi, I've two tables:
Product:
ProductID
ProductName
StateLog:
StateLogID
ProductID (Foreign Key)
State (bit)
TimeStramp (DateTime)
I need to find the heighest StateLog.TimeStamp for each StateLog.ProductID there have the StateLog.State = 0
Something like this:
SELECT
*
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_NAME ='FK_TreeNodesBinaryAssets_BinaryAssets'
and TABLE_NAME = 'TreeNodesBinaryAssets'
but for indexes.
I'm trying to a good Perl module to use for connecting to a Sybase database.
My Googling has led me to see sybperl as a possible choice, but it hasn't been updated since 2005.
StringBuilder sb = new StringBuilder();
sb.AppendLine("SELECT");
sb.AppendLine(String.Format(" (SELECT TOP 1 CAST(ProspectID AS VARCHAR(5)) FROM Lead_Import_Fail Where ProspectID < {0} AND ProspectFullName = '{1}')", Convert.ToInt64(lead.LeadID), lead.Name));
sb.AppendLine(String.Format(", (SELECT TOP 1 CAST(ProspectID AS VARCHAR(5)) FROM Lead_Import_Fail Where ProspectID < {0} AND ProspectNRICPassport = '{1}')", Convert.ToInt64(lead.LeadID), lead.NRIC));
Thanks in advance.
So I'm not able to user enterprise manager to do this... If I was I wouldn't even be asking this question. So I'm wondering if there is a way through TSQL to execute a command that maps a User to a particular Database and grants them 'owner' permissions.
Thanks...
Hi
I have a huge mysql dump file generated from phpmyAdmin (150 000 lines of create table, inserts....)
The mySql query tool fails to open such a big file.
As a result i can't insert all the records.
Is there a way to do this ?
Thanks
John
ISNULL(SUM(MyTable.Total), 0) AS Total
how can i modify the above statement to also check if Total is less than 0 (zero), such that if Total is NULL or less than 0 (negative), i assign 0 to Total
I can't seem to find this in the mysql manual:
How do you enter multiple conditions for the same field in a select statement?
e.g.:
SELECT * FROM table WHERE ID = '1, 2, 3, 4'
Is there a way to do this without using this:
SELECT * FROM table WHERE ID = '1' OR ID = '2' OR ID = '3' OR ID = '4'
mysql> select 0.121='0.121';
+---------------+
| 0.121='0.121' |
+---------------+
| 1 |
+---------------+
Does it hold for other database that number='number' is true?
I have 3 tables, with 3 fields all the same. I basically want to select information from each table
For example:
userid = 1
I want to select data from all 3 tables, where userid = 1
I am currently using:
SELECT r.*,
p.*,
l.*
FROM random r
LEFT JOIN pandom p ON r.userid = p.userid
LEFT JOIN landom l ON l.userid = r.userid
WHERE r.userid = '1'
LIMIT 0, 30
But it doesn't seem to work.
I'm attempting to create an anti-bruteforcer for the login page on a website. Unfortunately, my query is not working as expected. I would like to test how many times an IP address has attempted to login, and also return the ID of the user for my next step in the login process. However, I'm having a problem with the query... for one thing, this would only return rows if it was the same user as they had been trying to login to before. I need it to be any user. Secondly, regardless of whether I use LEFT JOIN, RIGHT JOIN, INNER JOIN or JOIN, it will not return the user's ID unless there is a row for the user in login_attempts.
SELECT COUNT(`la`.`id`), `u`.`id`
FROM `users` AS `u` LEFT JOIN `login_attempts` AS `la`
ON `u`.`id` = `la`.`user_id`
WHERE `u`.`username` = 'admin' AND `la`.`ip_address` = '127.0.0.1' AND `la`.`timestamp` >= '1'
Would this using close this _connection?
using(SqlConnection _connection = Class1.GetSqlConnection())
{ //code inside the connection
}
//connection should be closed/ended?
I'm just wondering because GetSqlConnection() is a static function of Class1 and the whole connection might not be closed because it is calling outside class' static function instead of straight?
using(SqlConnection _connection = new SqlConnection(_connectionString)
{ //code inside the connection
}
Hi,
I am using timestampdiff in derby db to retrieve the time difference between 2 time: startdate, and enddate. e.g.
startdate = 2010-02-23 02:59:52.045
enddate = 2010-02-23 03:45:39.898
select {fn timestampdiff(SQL_TSI_HOUR, startdate, enddate)} as diff
I would like to know how can I get the time diff in hours, e.g. 0.25, etc?
Thank you.
Hi!! Im having a problem, Im trying to do a query... I remember that in the past I did something like this but today this query is returning nothing, no error, no data, just nothing... the query is something like this:
SELECT field1, @variableX:=field2
FROM table
WHERE
(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=0)0 AND
(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=4)=0;
I also tried this query but it didnt work (also it gaves no error):
SELECT field1, @variableX:=field2,
@variableY:=(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=0),
@variableZ:=(SELECT COUNT(fieldA) FROM table2 WHERE fieldB=@variableX AND fieldC=4)
FROM table
WHERE @variableY0 AND @variableZ=0;
As you can see, what Im trying to do in the 1st query is use a variable in the conditions; in the 2nd query Im trying to create some variables and evaluate them in the conditions. At the end in the 2nd query the @variableY=1 AND @variableZ=0 but I dont know what the query returns an empty data
What could be wrong here??? Any comment or suggest is welcome!!! thanks!!!
Bye!!!
i have tables
profiles (id, name, deleted)
categories (id, name, deleted)
profiles_categories (id, profile_id, category_id, , deleted)
I have wrong query
SELECT p.id, p.name CONCAT_WS(', ', c.name) AS keywords_categories
FROM profiles p
LEFT JOIN profiles_categories pc ON p.id = pc.profile_id
LEFT JOIN categories c ON pc.id = c.id
WHERE p.deleted = FALSE
So, i want have result with all profiles with concan categories.name.
Thanks
Kind of a whimsical question, always something I've wondered about and I figure knowing why it does what it does might deepen my understanding a bit.
Let's say I do "SELECT TOP 10 * FROM TableName". In short timeframes, the same 10 rows come back, so it doesn't seem random. They weren't the first or last created. In my massive sample size of...one table, it isn't returning the min or max auto-incrementing primary key value.
I also figure the problem gets more complex when taking joins into account.
My database of choice is MSSQL, but I figure this might be an interesting question regardless of the platform.
in plain english can you explain to me what happens here:
rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable
what i need to do is to be able to insert values into a table called batchinfo. would this be the best way to do an OPEN?
the only thing i would be doing is inserting values.
I have a table with stock quotes that looks something like this:
id, date, stock_id, value
Every day has several rows for each stock_id (it is automatically updated every five minutes), so the table is rather big at the moment.
How do i delete every row but the last one each day for every stock_id?
When we try to create a view within a funcion we get ERROR: there is no parameter $1. This is the sample code.
Begin
CREATE VIEW artikelnr AS
SELECT datum, 'uitgifte' as "type", CASE WHEN 'test'='test' THEN 0 END as "aantal ontvangen", aantal as "aantal uitgegeven"
FROM uitgifteregel
JOIN artikel ON artikel.artikelnr = new.artikelnr
JOIN uitgifte ON uitgifte.uitgiftenr = uitgifteregel.uitgiftenr
UNION
SELECT datum, 'ontvangst' as "type", aantal as "aantal ontvangen" , CASE WHEN 'test'='test' THEN 0 END as "aantal uitgegeven"
FROM ontvangstregel
JOIN artikel ON artikel.artikelnr = new.artikelnr
JOIN ontvangst ON ontvangst.ontvangstnr = ontvangstregel.ontvangstnr;
Return new;
end;
When we replace new.artikelnr on line 7 with value 1 it works like it should, but the function needs to work with different artikelnr's.
example line 7: JOIN artikel ON artikel.artikelnr = new.artikelnr
Please point us in the right direction.
Say you have a user table and an order table which references user (user has_many orders) and contains an item count field.
How could you efficiently ask "how many uses ordered how many items?"
That is, to generate something along the lines of:
Number of users | sum of items
-------------------------------
5 users | 1 item
4 users | 5 items
1 user | 7 items
Thanks in advance.