UPDATE static
SET money = money + '100'
WHERE member_id IN (SELECT member_id FROM race WHERE race_id = '$race_id')"
I want to retrieve member_ids and give for all of them +100 money. What's wrong?
UPDATE statistics'
SET money = money + '$money'
WHERE member_id IN ((SELECT member_id FROM races WHERE l_id = '$mem_id'), $other_id)
What's wrong with that? I want to retrieve all member_ids from races and also include to member_id $other_id. Without $other_id it works.
By the way, it gives me "Subquery returns more than 1 row" error.
If I have two tables; Drivers keyed by DriverId and Trips with foreign keys DriverId and CoDriverId, and I want to find all trips where a driver was either the driver or co-driver I could code this in Transact-SQL as
select d.DriverId, t.TripId
from Trips t inner join Drivers d
on t.DriverId = d.DriverId or t.CoDriverId = d.DriverId
How could this be coded as a LINQ query?
Hi
I am using two different databases for my project.
Oracle and apache derby and trying to use as much as possible ansi sql syntax supported by both of the databases.
I have a table with column amount_paid NUMERIC(26,2), in a table.
My old code which was using oracle db need to retrieve value in this format
SELECT LTRIM(TO_CHAR(amount_paid,'9,999,999,999,999.99')) .
How can i do this using ANSI sql syntax.
Any suggestions for a real simple C library to query a single MySQL table, nothing fancy here. Just doing a single select * from a table. Any help is appreciated.
I have an excel spreadsheet that I want to import select columns into my database table. the wiz didn't offer that option.
any easy code options?
Thanks
newbie
HELP! For some reason when I create a custom edit or display form, all the lookup fields are showing in a weird way or not showing any value at all, can someone explain to me how I am suppose to fix that, I know it has something to do where it say select="@value" in the display form.
Please help me out.
Thank you.
If you do a search for:
http://www.google.co.uk/search?q=0x57414954464F522044454C4159202730303A30303A313527&hl=en&start=30&sa=N
you will see a lot of examples of an attempted hack along the lines of:
1) declare @q varchar(8000) select @q = 0x57414954464F522044454C4159202730303A30303A313527 exec(@q) --
What is exactly is it trying to do? Which db is it trying to work on?
Do you know of any advisories about this?
sorry if this is a repeat, i looked around some and didnt find what i was after so here goes
SELECT * FROM trees WHERE trees.`title` LIKE '%elm%'
this works fine, but not if the tree is named Elm or ELM ect... how do i make sql case insensitive for this wild-card search?
again apologies if this is repeated.
oh, using MySql 5 on apache
I am using VS2010 and C#
When I map/select my database tables with LINQ to SQL I have to option to change the "member" propery, but when i delete the table (because I changed something in the schema for example) and add it again the member value gets "reset". Is it possible to set/override this member programmaticly, so that I dont have to change it by hand everytime
I mean the member option of
'<'Table Name="dbo.table1" Member="table1"
I have a table view controller which doesn't let me manually scroll to the last row. It automatically scrolls slightly up so I could never select the last 2-3 rows. Anyone experienced this problem? Should I set a minimum height for the table view to solve this? If so how?
I have an ancient code snippet I use for copying tables in MySQL.
CREATE TABLE new_table (select * from old_table);
This works great, with one exception. It doesn't copy the primary key or other table indexes.
Is there any way to copy a table in MySQL AND include the indexes/primary key??
We're trailing the use of the built in bug tracking, and have written some integration into our helpdesk software that allows for escalation via workitems.
One thing I haven't found out how to do, is to merge all changes associated with a work item (say to go from dev branch to main) - I appreciate you can double click on a changeset in the merge dialog to view if it is associated with a workitem, and also that I can select individual changesets, and groups of adjacent changesets; but there doesn't appear to be any way to merge changes by workitem?
Query:
select t1.col1
from table1 t1
inner join with (nolock) table2 t2 on t1.col2 = t2.col1
Am trying to use nolock option for optimized query in mySQL db, but for some reason the above query
does not work and the error i receive is
You have an error in your SQL syntax;
Any thoughts?
Hi fellow coders
I'm new at LINQ, searching the net for LINQ samples that mimic SQL's LIKE statement doesn't satisfy myself.
What I want is producing the same query result as this SQL
SELECT * FROM table_1 WHERE column_1 LIKE '__0%'
I want to query from table_1 where column_1's third character is '0'
Is there equivalent statement in LINQ
:D thank you
i have a table (tbl_world) which look like this
id | first_name | last_name | age | class |
now i want to search the text which can be anywhere in first_name or in last_name
i m using below mysql query
"SELECT * FROM tbl_world WHERE REGEXP '".$word."' IN( first_name, last_name)";
where $word is user input (means if i search 'hell' then 'hello' as well as 'wellhell' also returned in result)
above query display error, please suggest me optimize method for search in mysql.
addition question: should i use LIKR or RLIKE?
hi guys
really i don't know what im doing wrong... i am trying to process multiple radios with mysql. the first step has involved me echoing the results on the process page. each time i select any radio option it simply displays the first row result. this is that i see after trying to submit the form:
Notifications
Thank you. The notifications have been updated successfully.
statusid: 14 notc2: 1
Return
this is the code for the form:
<div style="padding: 15px;">
<span class="loginfail" style="font-size:24px; font-weight: bold">Notifications</span><p>
<?php include("progress_insertcomment.php"); ?>
<?php
// Make a MySQL Connection
mysql_select_db("speedycm_data") or die(mysql_error());
$query_comment = "select * from tbl_alert order by id desc limit 1";
$comment = mysql_query($query_comment, $speedycms) or die(mysql_error());
$row_comment = mysql_fetch_assoc($comment);
$totalRows_comment = mysql_num_rows($comment);
?>
<!--- add notification --->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<span id="sprytextarea1">
<textarea id='comment' name="comment" style="height: 75px; width:330px;"><?php echo $row_comment['comment']; ?></textarea>
</span>
<p>
<button type="submit">Add</button>
<input type="hidden" name="notc" value="1"/>
</form>
<!--- notification history --->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="2" cellpadding="2">
<?php
if ( $row_comment == 0 ) {
echo "<span style='font-size: 11px;'>No current alerts.</span>";
} else {
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM tbl_alert ORDER BY id DESC")
or die(mysql_error());
while($rows=mysql_fetch_array($result)){ ?>
<tr>
<td>
<?php
echo "<div class='bubble'><div class='pimped'>
<blockquote>" . $rows['comment'] . "
</blockquote></div>
<cite><strong>" . $rows['user'] . "</strong> @ " . $rows['date'] . "</cite>
<span style='font-size: 10px;'>
<p>
<a href='editalert.php?id=". $rows['id'] ."' class='form' >Edit</a> • <a href='deletealert.php?id=". $rows['id'] ."' class='form'>Delete</a>
</span>
</div>
";
?>
</td>
<td valign="top" align="center"><div style="padding-left: 30px;"><span style="font-size: 10px;">Completed?</span>
<p class="field switch">
<!--- determine status of notification --->
<?php
$status = $rows['status'];
$id = $rows['id'];
?>
<input type="radio" name="selstatus[<?php echo $id; ?>]" value="no" <?php if($status == 'yes') {echo 'checked';} else {echo '';} ?>/>
<input type="radio" name="selstatus[<?php echo $id; ?>]" value="yes" <?php if($status == 'yes') {echo 'checked';} else {echo '';} ?>/>
<input type="hidden" name="statusid" value="<?php echo $id; ?>"/>
<label for="radio1" class="cb-enable <?php if($status == 'yes') {echo 'selected';} else {echo '';} ?>"><span>Yes</span></label>
<label for="radio2" class="cb-disable <?php if($status == 'no') {echo 'selected';} else {echo '';} ?>"><span>No</span></label>
</p>
</div></td>
</tr>
<tr>
<td></td>
<?php
}
}
?>
<td align="center"><div style="padding-left: 30px;">
<button type="submit">Update</button>
<input type="hidden" name="notc2" value="1"/>
</div></td>
</tr>
</table>
</form>
</div>
this is the code for the processing page:
<?php
// 6) update notifications
if (array_key_exists('notc2',$_POST)) {
$update = $_POST['selstatus'];
echo "<p style='font-size: 12px;'>Thank you. The notifications have been updated successfully.<p>";
foreach($_POST as $key => $value){
echo $key . ': ' . $value . '<br>';
}
echo "<p><span style='font-size: 12px;'>
<a onClick=\"history.go(-1)\" class='form'>Return</a></p>
<p></span>
";
exit;
};
?>
how do i resolve this problem? please any help would be appreciated. i would like to display the id and value of the selected checkbox on the processing page before inserting it into the table. thanking you in advance.
GOD BLESS
I'm doing select sum(clicks), date from stats group by date;, however when the sum is null for some date, the whole row is discarded, I want to see: | null | some_date |, how to do so?
Cheers,
I seem to keep running into little tidbits that help drastically in different areas of different languages.
For instance, a few days ago I learned about EXPLAIN SELECT... for any MySQL query that seems to be going slow. It took my 196 second query to 0.0084 seconds.
I would like to use Linq instead of below function :
Friend Function IsCollectionInTable2(ByVal apps As DataTable, ByVal collectionId As String) As Boolean
For Each row As DataRow In apps.Rows
If row("CollectionId").ToString = collectionId Then Return True
Next
Return False
End Function
The best I can do is below:
Friend Function IsCollectionInTable(ByVal apps As DataTable, ByVal collectionId As String) As Boolean
Return (From row In apps.AsEnumerable()
Where (row.Field(Of String)("CollectionId") = collectionId)
Select row.Field(Of String)("CollectionId")).Count > 0
End Function
I would like to use Exists or Any in above function. Performance could be an issue,
$sql = 'SELECT
id,
DATE_FORMAT(date,"%d.%m.%Y - %H.%i Uhr") AS dat,
user1,
user2,
p_user1,
p_user2,
be_user1,
be_user2,
win
FROM
kok_1on1_matches
WHERE
user1="$user"
OR
user2="$user"';
What is wrong with the WHERE statement?
SELECT TotalItems.Total_Items
,TotalItems.No_Items_Present
,ItemsTable.No_Of_Items_Ret
FROM TotalItems
INNER JOIN ItemsTable ON
ItemsTable.Item_Name= '" + DropItemName.SelectedValue + "'"
this is my SQL query what I want is to retrieve two column values corresponding to the item I enter in my dropdown list from one table and the no_of_items_ret from another table satisfying the condition of the dropdownlist
I'm getting all the values corresponding to any item I enter what should i do?
I have indexes for my table user,date, and date,user but when I issue queries like
SELECT * FROM table WHERE date >= '2010-5-1' and user='test';
It doesn't use the date,user index it uses the user index. Is there any way to get mysql to use the date,user index for these queries?
I have this weird situation:
When I do on rails console Time.now or Time.zone.now I get the same values (suppose they run at the sime time: 2014-06-05 23:38:06 -0300)
But when I use Time.now in a query like: Match.where("datetime = ?", Time.now) it returns the time 3 hours ahead!
.to_sql output:
SELECT `matches`.* FROM `matches` WHERE (datetime = '2014-06-06 02:38:06')
any thoughts on that?
Rails 4
Mysql 5.5