Imaginary Situation: You’ve used mysqldump to create a backup of a mysql database. This database has columns that are blobs. That means your “text” dump files contains both strings and binary data (binary data stored as strings?)
If you cat this file to the screen
$ cat dump.mysql
you’ll often get unexpected results. The terminal ...
Hello,
I have two stored procedures and one trigger for a class I am taking that are done in sql server 2005. I want to recreate them in mysql with phpmyadmin. Everytime i put them in I get a 1064 error. Is this becuase phpmyadmin does not handle stored procedures or triggers well, or is it becuase the syntax from sql server 2005 to m...
Hello, I'm trying to fetch the most popular tags from all videos in my database (ignoring blank tags). I also need the 'flv' for each tag. I have this working as I want if each video has one tag:
SELECT tag_1, flv, COUNT(tag_1) AS tagcount
FROM videos
WHERE NOT tag_1=''
GROUP BY tag_1
ORDER BY tagcount DESC LIMIT 0, 10
Howeve...
I have a table recording the amount of data transferred by a given service on a given date. One record is entered daily for a given service.
I'd like to be able to retrieve the most recent amount for a set of services.
Example data set:
serviceId | amount | date
-------------------------------
1 | 8 | 2010-04-12
2 ...
User writes a series of tags (, separated) and posts the form.
I build an array containing the tags and delete dupes with array_unique() php function.
I'm thinking of doing:
go through the array with foreach($newarray as $item) { ... }
check each $item for existence in the tags mySQL table
if item does not exists, insert into ...
I've got several div id's, each containing a different client. I want to be able to click the delete button and using ajax and jquery delete the specific div from the database. I'm getting success in AJAX but it's not deleting anything from the DB. And then obviously, upon deletion, I would like the container to reload dynamically. help...
I have generally always used some sort of Hungarian Notation for my field names in my tables e.g.
#Table Users
u_id, u_name, u_email etc...
#Posts
p_id, p_u_id, p_title, p_content etc...
But I have recently been told that this isn't best practice. Is there a more standard way of doing this? I haven't really liked just using the field...
Yo.
I'm really quite new to this whole JavaScript business, not to mention AJAX, so I was thinking if you guys could help me out with a conundrum.
Basically, what I want is for the user to be notified upon a change in a value of a MySQL table. How should I go about that? Should I use jQuery, or can I slap something together myself?
Th...
My current query reads:
SELECT entry_id, user_id, cat_id, AVG( rating ) as avg_rate
FROM `entry_rate`
WHERE 1
GROUP BY entry_id
cat_id relates to different categories: 1, 2, 3 or 4
Is there a way I can find the maximum average for each user in each category without setting up an additional table? The return could potentially be 4 max...
$s = explode (" ", microtime());
$s = $s[0]+$s[1];
$con = mysqli_connect ('localhost', 'test', 'pass', 'db') or die('Err');
for ($i=0; $i<1000; $i++) {
$stmt = $con -> prepare( " SELECT MAX(id) AS max_id , MIN(id) AS min_id FROM tb ");
$stmt -> execute();
$stmt->bind_result($M,$m);
$stmt->free_result();
$rand = mt_rand( $m , ...
The following query takes FOREVER to execute (30+ hrs on a Macbook w/4gig ram) - I'm looking for ways to make it run more efficiently. Any thoughts are appreciated!
CREATE TABLE fc AS
SELECT threadid,
title,
body,
date,
userlogin
FROM f
WHERE pid
NOT IN (SELECT pid FROM ft) ORDER BY date;
(table "f" is ~1 Gig ...
I'm trying to write an SQL statement that will generate an SQL script that will update a BLOB field with an IMAGE being selected from the database.
This is what I have:
select concat( 'UPDATE `IMAGE` SET THUMBNAIL = ',
QUOTE( THUMBNAIL ),
' WHERE ID = ', ID, ';' ) as UPDATE_STATEMENT
from IMAGE;
In t...
I have a bit of an issue with a site I maintain. I have been asked to add a report to a page that sits in a jsp page. The reporting information comes from a MySQL database. The problem is to connect the jsp to the database would require added functions to code that I do not have the original source of. I thought about redoing all the db ...
I'm working on a forum-like webapp where I'd like to allow users to favourite an item so that they can keep track of it, and also so that others can see how many times an item's been favourited.
The problem is, I'm unsure on the best practices for databases, which includes this situation.
I have two ideas in my head on how to do this:
...
I'm trying to add suggestions to product pages along the lines of : "Customers who purchased this item also purchased x and y".
The way the data is compiled right now is a mysql table with 3 rows.
PRODUCT | CUSTOMER |QUANTITY
Product is the product ID. Customer is the customer ID. Quantity is the number of time that product was bou...
I'm trying to create a table for pseudo array variable. That looks like
CREATE TABLE IF NOT EXISTS `MyArray`.`ArrayTable` (
`ID` INT UNSIGNED NOT NULL COMMENT 'Hash value of SessionID + ArrayName' ,
`SessionID` INT UNSIGNED NOT NULL ,
`ArrayName` CHAR(26) NOT NULL
COMMENT '32 digit char - 6 digit longest process id (as...
What I want to do is get the data from two different tables (table1 and table2) where row1 = 'test' in both of the tables
...
Php novice.
1.Is there anything wrong with this PHP & MySQL code?
include_once "db_login.php" ;
$sql = "DROP TEMPORARY TABLE IF EXISTS temp_sap_id_select" ;
mysql_query ( $sql ) or ( "Error " . mysql_error () ) ;
$sql = " CREATE TEMPORARY TABLE temp_sap_id_select
(
`current_page` INT NOT NULL,
...
My two tables look like this:
TABLE1 TABLE2
+--------------------+ +--------------------+
|field1|field2|field3| and |field2|field4|field5|
+--------------------+ +--------------------+
I am already running a SELECT query for TABLE1, and assorting all of the data into variables:
$query = "SELECT...
For example, i want to search a word 'marple', this should return row with near or exact word like 'marble','maple','marple', etc...
How to do it in mysql query? or better give word suggestion if any?
Thanks,
...