Hi,
is it possible to use date_sub like this ?
$dt = date("Y-m-d h:i:s");
$query = "INSERT INTO `table` (`date`) VALUES ('DATE_SUB('$dt', INTERVAL 15 DAY)')";
$result = MYSQL_QUERY($query);
Thanks
I don't know the best way to title this question but am trying to accomplish the following goal:
When a client logs into their profile, they are presented with a link to download data from an existing database in CSV format. The process works, however, I would like for this data to be 'fresh' each time they click the link so my plan was - once a user has clicked the link and downloaded the CSV file, the database table would 'erase' all of its data and start fresh (be empty) until the next set of data populated it.
My EXISTING CSV creation code:
<?php
$host = 'localhost';
$user = 'username';
$pass = 'password';
$db = 'database';
$table = 'tablename';
$file = 'export';
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field'].", ";
$i++;
}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= '"'.$rowr[$j].'",';
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
any ideas?
So, I have three tables with the following rows: Customers (Customer_id and Name), Orders (Customer_id, Product_id, Quantity) and Products (Price).
How do I write a query which shows all customers who spent more than 1000$? Do I have to join the tables?
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?
table1 has column CITY and COUNTRY. table2 has column CITY.
how do i delete from table2 all records that have CITY in common with table1 but also the COUNTRY='Russia' ??
please keep in mind that both tables have about 1 million rows of data
i am doing:
explain select * from calibration;
it says 521332 rows
when i do:
select count(*) from calibration;
i am getting 521961
can someone explain whats going on here?
"insert into NodeProfileSections (profile_no, tpl_section_no)
select (np.profile_no, tps.tpl_section_no)
from NodeProfile np, TemplateProfileSection tps, TemplateProfile tp
where np.hostname = '%s' AND np.role = '%s' AND tp.tpl_profile_no = tps.tpl_profile_no
AND tp.tpl_name = '%s' AND tp.role = '%s' AND tps.tpl_section_name = '%s';"
%(hostname, role, template_name, role, section_name)
error_message = 'Operand should contain 1 column(s)'
How to solve this problem?
I'm trying to use this code to check if the system already exists a field with this value
Dim adap As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM client WHERE code ='"+ TxtCode.Text +"'"
Dim comand As New MySqlCommand()
comand.Connection = con
comand.CommandText = sqlquery
adap.SelectCommand = comand
Dim data As MySqlDataReader
data = comando2.ExecuteReader()
leitor.Read()
If (data(3).ToString) = code Then
MsgBox("already exists", MsgBoxStyle.Information)
TxtCode.ResetText()
TxtCode.Focus()
Else
Console.WriteLine(insert("INSERT INTO client (name, tel, code) VALUES ('" & name & "', '" & tel & "')"))
con.Close()
End If
Hi
I have asked this question before in this forum and they told me that it will retun an empty result set,I want to know that if I set the column with null values it will retun an empty result set?also the ANSI_NULLS is OFF ,thanks
SELECT 'A' FROM T WHERE A = NULL;
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 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 my own server (with root access).
I need statistics of users who visit my website etc etc...
I have looked at an app called Webalyzer...
Is this a good choice?
I run apache2 on a Ubuntu 9 system...
If you know of any good statistics apps for servers please let me know.
And a follow-up question: All statistics are saved in log-files right? So how large would these log-files become then? Possibility to split them would be good, dont know if this is possible with Webalyzer though...
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'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 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.
Basically I want to do this:
SELECT * FROM `table` WHERE x = 'hello' OR x = 'bye' LIMIT 1';
I want it to return 1 value, but to prioritize results from the 1st where clause. So if there exists a row where column x's value is "hello", it will not return the result from the 'bye' value. If the "hello" value doesn't exist though, it will return the result from the 'bye' value.
Can't figure out a way to do it even though it seems fairly trivial. Any ideas?
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 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 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.
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()");
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>";
}