I just ran a command
update sometable set col = '1';
by mistake without specifying the where condition.
Is it possible to recover the previous version of the table?
I am creating a secure web based API that uses HTTPS however if I allow the users to configure it (include sending password) using a query string will this also be secure or should I force it to be done via a POST?
I have a 1 : M relationship.
I built a dynamic query based on input from users to return the listing of parents entities along with their children (using predicate builder:
(done successfully new TDataContext().Ps.Where(predicate) )...
but need to order the results by a field found only on the child entities.
I'm at a loss: new TDataContext().Ps.Where(predicate).OrderBy(p = p.Cs. ??)
where Ps = parents collection relationship with Cs = child entities
any help appreciated.
Hi,
Is it possible to run a query on an EF4.0 data context and get all objects of a certain type?
Say the context has books, genres & authors but I only have a generic parameter, t. Is it possible to get all of type just by using this t?
I don't think it is :(
I'm querying a big mysql database with only read privileges, and I'd like to set some slow query results to a variable, 'foo', so I can use them again in other queries.
I get, ERROR 1193 (HY000): Unknown system variable '$foo'
when I enter:
set $foo := (select *
from table1 join table2
where bar = 0
group by id);
Is there a way to do this with variables, since I don't have privileges to create temporary tables?
re,
I have a simple query that works:
$("#test fieldset input").each(function() { })
However, I want to select "input" and "select" elements without having to write 2 "each" queries. Is this possible?
thanks.
I have 2 tables:
Table A: code | name
Table B: barcode | name
Table B has full barcode and name, Table A has only code.
I need to run update query that fill name in Table A.
I tried something like:
update A set name = (select top 1 Name from B where B.Code = mid(A.Barcode,1,8))
but it doesn't work.
The error-Warning: sqlite_query() [function.sqlite-query]: attempt to write a readonly database is coming whenever i try to insert values into a sqllite 1.1 database thru php program.
php version is 5.2.
My Python server receives jobs that contain a list of the items to act against, rather like a search query term; an example input:
(Customer:24 OR Customer:24 OR (Group:NW NOT Customer:26))
To complicate matters, customers can join and leave groups at any time, and the job should be updated live when this happens.
How is best to parse, apply and store (in my RDBMS) this kind of list of constraints?
Hey all,
I have a table Logins { Id, AccessTime }, I'd like to write a query that returns 3 columns, Total Logins during a time period, Unique Logins for a time period, and the Id of the user.
I know I could do this with two passes and a join, is there a better way to do it in a single pass?
Thanks,
~P
I need to update multiple rows with different values.Is it possible to do in mysql?
ie,some thing like this
UPDATE landing_page SET (rotation_slot_begin='0',rotation_slot_end='0.333333333333' where landing_pageid=265),(rotation_slot_begin='0.333333333333',rotation_slot_end='0.666666666667' where landing_pageid=267),(rotation_slot_begin='0.666666666667',rotation_slot_end='1' where landing_pageid=268)
but this query is not working.I think something like this.Anybody can help me please
Hey guys
how can i query my mysql database and fetch rows which are posted in earlier 3 days
i know how to fetch todays's rows but not 3 days ago
time will save in my table like this :
2010-01-20 19:17:49
and this is what i know :
SELECT id FROM pages WHERE date=now()
but i need to show posts in 3days
and im looking for a simple and straight solution ,because i know how to do so in long php codes
I am trying to create a type of recorded data transaction that I can replay on a different database.
For example I am capturing an order into a system, when I save that I want to be able to "export" a sql script that I can run on another database to create the same order.
I am using NHibernate and I am trying to catch the sql query string for the save operation to save to a file, but with no success.
I am calling the results form a query to a list on my site based on if the item is "downtown_hosted". This works fine but I would now like to sort that list DESC, but can't seem to get the syntax correct.
Below is what I have:
$result_events = mysql_query("SELECT * FROM events WHERE downtown='downtown_hosted' ORDER BY date DESC LIMIT 5 ");
i am downloading files from server using WinSCP.Is it possible to write a query to download a large database using mysql query? Or using any other method
i have tried with this code but i am not able to get the whole database structure
<?php
if(file_exists('backup_sql/my_backup.zip'))
{
unlink('backup_sql/my_backup.zip');
}
$tables='*';
$host='MY HOST NAME';
$user='MY_USERNAME';
$pass='MYPASSWORD';
$name='MY_DB_NAME';
$link = mysql_connect($host,$user,$pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
$return='';
//cycle through
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
//$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
//$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
$rand_var=time();
$files_to_zip = array(
"'backup_sql/db-backup-'.$rand_var.'.sql'",
);
$name = 'db-backup-'.$rand_var.'.sql';
$data = $return;
?>
any one please help me... thank you
Good day!
Please, can you help me to translate such a mysql query into nhibernate
SELECT sales_id, service_id,dayofyear(dt), max(dt) FROM clients.statistics group by sales_id, service_id,dayofyear(dt);
J2EE has ServletRequest.getParameterValues().
On non-EE platforms, URL.getQuery() simply returns a string.
What's the normal way to properly parse the query string in a URL when not on J2EE?
I have table 'products' and I need to update 'price' field by 20% if product 'type' field is "imported".
How do I read and update field at the same time in my UPDATE query?
Using Delphi 2009 + Firebird 2.1.3.
Database is ODS 11.1, default char set is UTF8.
My prepared query is as follows:
SELECT
a.po_id, a.po_no
FROM
purchase_order a
WHERE EXISTS
(SELECT 1
FROM
sales_order_item z1
JOIN
purchase_order_item z2
ON
z2.so_item_id = z1.so_item_id
AND
z2.po_id = a.po_id
WHERE z1.so_id = :soid)
ORDER BY a.po_no
Now when I loop this say 1000 times because I have 1000 x so_id, the CPU usage get at 100% for FBSERVER.EXE
Anyone encountered this problem?
Where is the value of the actual query executed for an AccessDataSource with the parameters replaced with actual values?
Note: Answers in VB.NET or C# are fine.
This time my setup looks like this: one table with galleries names (gallery_id, gallery_name) and another table with galleries photos (photo_id, photo_gallery_id, photo_name).
What I need is to get all the galleries with one random picture for each gallery.
Is it possible to do this with a single query?
I need to do something like the following:
Find other categories people like based on the categories you like. I have a likes table, which is joined to users and categories.
I need to do an efficient query to find out what other categories people who liked a given category also like.
Any thoughts on this would be appreciated. Thanks in advance.
I want to insert into multiple tables in same query by using BEGIN and COMMIT.
It seems the error occur at begin.
here is my SQL command
BEGIN
INSERT INTO Product (pName, pBrand, pCategory, pSize, pQuantity, pPrice, pDetail)
VALUES('$name', '$brand', '$category', '$size', '$quantity', '$price', '$detail')
INSERT INTO Image (iName, iExt, iSize, pID)
VALUES('$img_name', '$img_ext', '$img_size', LAST_INSERT_ID());
COMMIT;