Can anyone please clarify what this query will return ?
SELECT TestCase FROM MyTable WHERE Verdict = 'PASS' AND
StartTime > DATE_SUB(NOW(), INTERVAL 2 MONTH)
I am getting this error while i am trying to delete a record the query is working but this line remains on the page. i want to echo "Deleted" written in the while should show up but the while loop is not working, i have tried and searched alot nothing helps!
mysql_fetch_array() expects parameter 1 to be resource, boolean given in delete.php on line 27
delete.php
<html>
<body>
<form method="post">
Id : <input type="text" name="id">
Name : <input type="text" name="name">
Description : <input type="text" name="des">
<input type="submit" value="delete" name="delete">
</form>
<?php
include("connect.php");
$id = $_POST['id'];
$name = $_POST['name'];
$des = $_POST['des'];
$result = mysql_query("DELETE FROM fact WHERE id='$id'") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "Deleted";
}
mysql_close($con); ?>
</body>
</html>
connect.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Dataentry", $con);
?>
How should i make the while loop work..
I've got 3 tables:
users (id, name, ...)
items (id, name, ...)
downloads (user_id, item_id, ...)
How do I get all users together with the number of downloads they have?
I'd like to select all records from a table (names) where lastname is not unique. Preferrably I would like to delete all records that are duplicates.
How would this be done?
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 need to show the number of online visitors, but there is a problem with selecting algoritm to do it!
maybe i must create a table in DB, where i'll store ip addresses of visitors and time of visit! by so i can show the count of ip addresses, which's time = NOW() - 10 minutes, for example...("now()-10 minutes" is just to show the logic, i know that this is not a function:)
is this goog way to go? or maybe it's better to use AJAX methods to store the data?
please give me an idea.
Thanks
I have indexes/primaries on all appropriate ID fields for each type. I'm wondering though how I could make this more efficient. It takes a while to load the page with only 15,000 rows and that'll quickly grow to 500k.
The $whereSql variable simply has a few more parameters for the main ebay_archive_listing table.
NOTE: This is all done in a single query because I have ASC/DESC sorting for each subquery value.
NOTE: I've converted some of the sub queries to INNER JOIN's
SELECT
product_master.product_id,
(
SELECT
COUNT(listing_id)
FROM ebay_archive_product_listing_assoc '.$listingCountJoin.'
WHERE ebay_archive_product_listing_assoc.product_id = product_master.product_id) as listing_count,
sku,
type_id,
(
SELECT
AVG(ebay_archive_listing.current_price)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.current_price > 0
) as average_bid_price,
(
SELECT
AVG(ebay_archive_listing.buy_it_now_price)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.buy_it_now_price > 0
) as average_buyout_price,
(
SELECT
MIN(ebay_archive_listing.current_price)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.current_price > 0
) as lowest_bid_price,
(
SELECT
MAX(ebay_archive_listing.current_price)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.current_price > 0
) as highest_bid_price,
(
SELECT
MIN(ebay_archive_listing.buy_it_now_price)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.current_price > 0
) as lowest_buyout_price,
(
SELECT
MAX(ebay_archive_listing.buy_it_now_price)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.current_price > 0
) as highest_buyout_price,
round(((
SELECT
COUNT(ebay_archive_listing.id)
FROM ebay_archive_listing
INNER JOIN ebay_archive_product_listing_assoc ON (
ebay_archive_product_listing_assoc.listing_id = ebay_archive_listing.id AND
ebay_archive_product_listing_assoc.product_id = product_master.product_id
)
WHERE '.$whereSql.' AND
ebay_archive_listing.status_id = 2
) / (
SELECT
COUNT(listing_id)
FROM ebay_archive_product_listing_assoc '.$listingCountJoin.'
WHERE ebay_archive_product_listing_assoc.product_id = product_master.product_id ) * 100), 1) as sold_percent
FROM product_master
'.$joinSql.'
WHERE product_master.product_id IN (
SELECT
product_id
FROM ebay_archive_product_listing_assoc
INNER JOIN ebay_archive_listing ON (
ebay_archive_listing.id = ebay_archive_product_listing_assoc.listing_id AND
'.$whereSql.'
)
)
I am trying to build a query that does a sum if a certain parameter is
set. For example:
SELECT SUM(IF(<condition>,field,field)) AS total_value
...which is working correctly.
But i have more than one condition in IF(), like:
SELECT SUM(IF(<condition> <condition>,field,field)) AS total_value
..which is not working, could you have any idea what should be the right query for this.
I am new to PhpMyAdmin.
I will like to create a foreign key for my tables.
In fact i have create tableI with this structures(A as int(11) autoincrement, B as varchar)
TableII ( A_2 as int(11) auto increment, B_2 as varchar, A as int(11).
I have declared A as an index in tableII, now when i go to relationship view to precise A as a foreign key i always have this error
Erreur lors de la création de la clé étrangère sur ID_Ville (vérifiez le type des colonnes)
Erreur
ALTER TABLE tb_quartier ADD FOREIGN KEY ( ID_Ville ) REFERENCES ingenieris2.tb_ville (
ID_Ville
) ON DELETE RESTRICT ;
Please Help
thanks!
How to add a custom value using LOAD DATA LOCAL INFILE?
The column time_added is the 7th column and the file has only 2 values for the first and the second column. For the 7th column, time_added I want to use the unix timestamp when loading from file.
This code isn't working:
$result = mysql_query("LOAD DATA LOCAL INFILE '{$myFile}' INTO TABLE {$table} FIELDS TERMINATED BY ':' LINES TERMINATED BY '\n' SET `time_added`=unix_timestamp()");
public ActionResult Example()
{
var q = from i in proba.name
select i;
return View();
}
How with this data make Json data and put them to table (on some View - no strongly typed)
I am trying to piece two queries together. Below is the code Im using. However the table is splitting up the data. How can I remedy this? Or what better solutions are there?
while($row = mysql_fetch_array($result))
{
echo "<tr id='centered' >"; echo "<td class='leftalign'>" . $row['Quarter_Name'] . "</td>";
echo "<td>" . $row['Quarterly_yield'] . "</td>";
echo "<td>" . $row['Quarterly_yield'] . "</td>";
echo "<td>" . $row['Quarterly_yield'] . "</td>";
}
while($row = mysql_fetch_array($result8))
{
echo "<td>" . $row['Quarterly_yield'] . "</td>";
}
We are looking for Web Designers & Developers. Urgent Opening.
Profile:-
a) Have exp. in Designing websites in wordpress
b) Have Creativity in work
c) Send us your work – [email protected]
d) Min Exp. required: 2 + years
e) Can Integrate the Facebook, Twitter & other social networking websites.
To review our profile – please check – www.dicorporation.com & www.ismoip.com
I just wanted to develop a translation app in a Django projects which enables registered users with certain permissions to translate every single message it appears in latest version.
My question is, what character set should I use for database tables in this translation app? Looks like some european language characters cannot be stored in UTF-8?
I have a table like:
gold
gold_city | gold_type | gold_selltime
-------------------------------------
city1 | type 1 | 2012-01-01
city1 | type 1 | 2012-02-02
city1 | type 1 | 2012-03-03
city2 | type 2 | 2012-01-01
city2 | type 2 | 2012-02-02
city2 | type 2 | 2012-03-03
city3 | type 3 | 2012-01-01
city3 | type 3 | 2012-02-02
city3 | type 3 | 2012-03-03
How can I get 1 last result order by gold_selltime desc each group by gold_city and gold_type
I used this:
SELECT * , COUNT( * )
FROM gold_2012
GROUP BY gold_type , gold_city
ORDER BY gold_selltime DESC
but it did work.
I only have result like:
gold_city | gold_type | gold_selltime
-------------------------------------
city1 | type 1 | 2012-01-01
city2 | type 2 | 2012-01-01
city3 | type 3 | 2012-01-01
but I need it like:
gold_city | gold_type | gold_selltime
-------------------------------------
city1 | type 1 | 2012-03-03
city2 | type 2 | 2012-03-03
city3 | type 3 | 2012-03-03
Lets say I have a SP that has a SELECT statements as follows,
SELECT product_id, product_price FROM product
WHERE product_type IN ('AA','BB','CC');
But data goes to that IN clause must be through a single variable that contains the string of values. Something link below
SELECT product_id, product_price FROM product
WHERE product_type IN (input_variables);
But its not working that way. Any idea how to do this?
Hi,
I need to perform a simple update query where the update should only be done, if there is no value with updating value (item_name). For example,
DB table [item_types]
item_id(PK) | item_name
Assuming there exist item_id with 6, My attempt is
UPDATE item_types as k SET k.item_name = 'item_1' WHERE NOT EXISTS (SELECT * FROM item_types as a WHERE a.item_name = 'item_1') AND k.item_id = '6'
But this gives me error
"You can't specify target table 'k' for update in FROM clause"
Could you please explain the error here and how can I achieve this ?
Thank you
I'm trying to a single value in my DB...When I run it through the console, it works correctly (as I'm replacing the variables with numbers and text).. However, My query is not running correctly. It's just prompting a syntax error Here is what I have:
"UPDATE books SET readstatus='".$readstatus."' WHERE book_id=".$book_id;
This won't work, I also tried doing something like this as I'm told this makes it a bit more secure? :
"UPDATE books SET readstatus='{$readstatus}', WHERE read_id='{read_id}'";
This does not prompt any errors, but no change is happeneing to the value in the DB, I'm guessing the syntax is incorrect.
Hey guys
Im trying to develop an advance consumer website using php and I stuck somewhere while trying to get the data with submitting to another page. All I want to do is to get the checkbox values which are stored in an array and checked by user. I urgently need your help please here is the code:
$sql2="SELECT * FROM alinanfis WHERE alinanfis.fis_id='".$fis."'" ;
$resultFis=mysql_query($sql2);
if(mysql_num_rows($resultFis)>0)
{
print "<form method='POST' action='deletionResult.php'>";
print "<table>";
print "<tr>";
print "<th style='background: transparent;'></th>";
print "<th>Fis No</th>";
print "<th>isim</th>";
print "<th>soyisim</th>";
print "<th >Tarih</th>";
print "<th>Fis Tipi</th>";
print "<th>Nerede</th>";
print "<th>Litre</th>";
print "<th>Tutar</th>";
print "</tr>";
while($rowAlinan=mysql_fetch_array($resultFis))
{
$sqlFisTipi="SELECT * FROM atype WHERE a_id='".$rowAlinan['a_id']."'" ;
$resultFisTipi=mysql_query($sqlFisTipi);
$rowFisTipi=mysql_fetch_array($resultFisTipi);
$sqlNerede="SELECT * FROM isyeri WHERE i_id='".$rowAlinan['nerde']."'" ;
$resultNerede=mysql_query($sqlNerede);
$rowNerede=mysql_fetch_array($resultNerede);
$sqlMID="SELECT * FROM musteri WHERE m_id='".$rowAlinan['m_id']."'" ;
$resultMID1=mysql_query($sqlMID);
$rowMID1=mysql_fetch_array($resultMID1);
print "<tr>";
print "<td><input name='checkBox[]' type='checkbox' value='".$rowAlinan['fis_id']."' />
php</td>";
print "<td>".$rowAlinan['fis_id']."</td>";
print "<td>".$rowMID1['m_name']."</td>";
print "<td>".$rowMID1['m_lastName']."</td>";
print "<td>".$rowAlinan['alinan_tarih']."</td>";
print "<td>".$rowFisTipi['a_name']."</td>";
print "<td>".$rowNerede['i_name']."</td>";
print "<td>".$rowAlinan['litre']."</td>";
print "<td>".$rowAlinan['tutar']."</td>";
print "</tr>";
}
print '<div class="form_settings">';
print "<input class='submit' type='submit' name= 'send' value='Send'>";
/
print '</div>';
print "</table>";
print "</form>";
}//end of if(num_rows>0)
else
echo '*no such receipt found!!';
mysql_close($con);
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
I have a table mytable( id, key, value). I realize that key is generating a lot of data redundancy since my key is a string. (my keys are really long, but repetititve) How do I build a separate table out that has (key, keyID) and then alternate my table to be mytable( id, keyID, value) and keyTable(keyID, key) ?