I am using MySQL.
I have several lookups like this:
SELECT * from users WHERE user_name LIKE '%search_term%'
What index do I need to make these lookups fast?
i am connecting to mysql from excel using odbc. the following illustrates how i am updating the rs
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("datapath") = dpath
.Fields("analysistime") = atime
.Fields("reporttime") = rtime
.Fields("lastcalib") = lcalib
.Fields("analystname") = aname
.Fields("reportname") = rname
.Fields("batchstate") = "bstate"
.Fields("instrument") = "NA"
.Update ' stores the new record
End With
the question is why is there a need to run cn.execute after this? havent i already updated the rs with rs.update?
Hi Bill
I am facing a problem in creating a trigger and i am not sure why this is erroring out.can you please help me.
I have described the problem in this link below
http://forums.mysql.com/read.php?99,365942,365942#msg-365942.
$resultnx = mysql_query("SELECT * FROM `emails` WHERE `email` = '{$email}'");
$num_rows = mysql_num_rows($resultnx);
gets this warning Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ....
Can any one please let me know the best way to use IF statement in mysql query to show if the "email" field is NULL then it should show as "no email"...
Postcode Telephone Email
----------------------------------------------------------
BS20 0QN 1275373088 no email
BS20 0QN 1275373088 no email
PO9 4HG 023 92474208 [email protected]
SO43 7DS 07801 715200 [email protected]
----------------------------------------------------------
How should I go about adding slashes to only single quotes and ignoring double quotes?
I am using php. I would only like to escape single quotes to prevent my php mysql queries from breaking.
Thank you!
I want to set the value of the column 'character_hold' to 'no' for all my rows in my MYSQL database. Is there a SQL statement I can use in phpmyadmin to set them all to 'no'?
I have a table of customers with a 1 recorded against their customerid on different dates.
I would like to find the sum of the 1's recorded in descending order. I'm using MySQL and php
Thanks
I am confused, I don't know what's wrong. I'm about to transfer all data from my first table to the other. Here is my code:
$getdata = mysql_query("SELECT Quantity, Description, Total FROM ordercart");
while($row = mysql_fetch_row($getdata))
{
foreach($row as $cell){
$query1 = mysql_query("INSERT INTO ordermem (Quantity, Description, Total) VALUES
($cell)",$connect);
}
mysql_free_result($getdata);
}
I get the error: Warning: mysql_fetch_row(): 5 is not a valid MySQL result resource.
i am creating a marks management system using php & mysqlwhere the concerned faculty will be able to login and enter the marks of the students. i can go with a simple table but the problem is there are 288 different subjects for which marks must be entered. So creating a mysql table with so many subjects does not look good for me. please suggest me the best way to manage user permissions so that only the corresponding faculty will be able to enter marks
Is there a simple :) and efficient way or reading very large number of rows sequentially using Zend_Db?
Basically I need to process entire table, row by row. Table is large, primary key sequence is not guaranteed(i.e. not an autoincrement, but is UNSIGNED INT).
What's the best way to approach this?
Environment: PHP 5.2, Zend Framework 1.10, MySQL 5.1
my website has PHP command:
mysql_query("SELECT * FROM users WHERE id=" . $_GET["id"]) or die(mysql_error());
When I enter URL
http://example.com/index.php?id=1;%20UPDATE%20users%20SET%20password=123%20WHERE%20id=1
I get following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE users SET password=abc WHERE id=1' at line 1
But in phpmyamin query executes successfully. What's wrong here? Why it doesn't execute in browser?
hi,
i am using php,mysql,jquery.
When a user clicks on save i go to back end and save data and show the response. once show the success i need to disable the save button for say 1 min. how do i do it.?
Currently I am using mysql to log all traffic from all users coming into a website that I manage. The database has grown to almost 11m rows in a month, and queries are getting quite slow. Is there a more efficient way to log user information? All we are storing is their request, useragent, and their ip, and associating it with a certain website.
I'm running mysql5 on Mac os x 10.5.8 and got this error.
How do I solve this?
The DB worked fine but stopped working after system update.
I think its something related to the socket file which is /tmp/mysql.sock
do I need to give it special permissions and owner?
Thanks
I have CMS table that contain CMS_STARTTIME and CMS_STOPTIME (attachment).
I want to create report to summarize exist data by using Date, Time and Year as Parameter (attachment).
I don't know how to create sql statement to meet this requirement. I'm using MySQL and MS-SQL.
Does one can help?
Thank you very much.
Hi,
I have two tables table1 and table2, i need to write a select query which will list me the columns that exist in both the tables.(mysql)
I need to do for different tables (2 at a time)
Is this possible?
I tried using INFORMATION_SCHEMA.COLUMNS but am not able to get it right.
how do i organize country data (countries, states and cities etc) in mysql?
cause every country has 3 tables: countries, states and cities.
should i have each country in separate set of tables or should i have them all in these 3 tables? if i have all of them in same tables, im afraid that the amount of rows will be huge cause i tend to have a lot of countries!
what is best practice for this?
My table has records for every minute (for instance the column name is date), now I want to fetch records with an interval of 5 minutes!
Can it be done at database level?
I am using Django with MySQL
I'm building a database class and thought it'd be a good idea to incorporate some form of SQL injection prevention (duh!). Here's the method that runs a database query:
class DB
{
var $db_host = 'localhost';
var $db_user = 'root';
var $db_passwd = '';
var $db_name = 'whatever';
function query($sql)
{
$this->result = mysql_query($sql, $this->link);
if(!$this->result)
{
$this->error(mysql_error());
} else {
return $this->result;
}
}
}
There's more in the class than that but I'm cutting it down just for this. The problem I'm facing is if I just use mysql_real_escape_string($sql, $this->link); then it escapes the entire query and leads to a SQL syntax error. How can I dynamically find the variables that need to be escaped? I want to avoid using mysql_real_escape_string() in my main code blocks, i'd rather have it in a function.
Thanks.
Hi,
I am storing images in mysql Db directly. what is the best way to display the image in good quality (thumbnail and original size images) using php.
I currently have this query which runs 2 of the exact same sub queries but pull different data. When I make the values comma separated it throws an SQL error saying the sub query can return only one value. Is there anything else I can do to avoid running multiple sub queries?
SELECT
product_id,
(
SELECT
COUNT(listing_id)
FROM ebay_archive_product_listing_assoc
WHERE product_id = product_master.product_id) as listing_count,
sku,
type_id,
(
SELECT
AVG(ebay_archive_listing.current_price),
AVG(ebay_archive_listing.buy_it_now_price)
FROM ebay_archive_listing
WHERE id IN (
SELECT listing_id FROM ebay_archive_product_listing_assoc WHERE product_id = product_master.product_id
) AND
ebay_archive_listing.start_time >= '.$startTimestamp.' AND
ebay_archive_listing.start_time <= '.$endTimestamp.' AND
ebay_archive_listing.current_price > 0
) as average_bid_price,
(
SELECT
FROM ebay_archive_listing
WHERE id IN (
SELECT listing_id FROM ebay_archive_product_listing_assoc WHERE product_id = product_master.product_id
) AND
ebay_archive_listing.start_time >= '.$startTimestamp.' AND
ebay_archive_listing.start_time <= '.$endTimestamp.' AND
ebay_archive_listing.buy_it_now_price > 0
) as average_buyout_price
FROM product_master
I'm aware of the syntax error... I'm selecting 2 seperate averages and am wondering if I can do it any simpler way.
What is the best way to store users passwords in a MySQL database using PHP. For example, md5 or is there something better? examples would be much appreciated.
I develop applications using PHP and MySQL. They're not trivial, though they're not too complex. As an example to that I have written an online application to enable football administrators manage the player, competition and judiciary processes.
Separately to that I have used Joomla to create websites for small businesses.
I'd like to be able to use Joomla as my online application development environment. Is there a way I can use Joomla for that?