mysql

What is the use of the "Partition" keyword in MySQL?

As I am a MySQL newbie. What does PARTITION mean in this MySQL statement? CREATE TABLE employees ( id INT NOT NULL, fname VARCHAR(30), lname VARCHAR(30), hired DATE NOT NULL DEFAULT '1970-01-01', separated DATE NOT NULL DEFAULT '9999-12-31', job_code INT NOT NULL, store_id INT NOT NULL ) PARTITION BY RANGE (s...

How do you edit a stored procedure in MySQL?

The title says it all. I can't seem to google the syntax for editing an already-created stored procedure in MySQL. I'd be happy with a link. ...

MySQL return Deadlock with insert row and FK is locked 'for update'

Hello developers! I get deadlock error in my mysql transaction. The simple example of my situation: Thread1 > BEGIN; Query OK, 0 rows affected (0.00 sec) Thread1 > SELECT * FROM A WHERE ID=1000 FOR UPDATE; 1 row in set (0.00 sec) Thread2 > BEGIN; Query OK, 0 rows affected (0.00 sec) Thread2 > INSERT INTO B (AID, NAME) VALUES (1000,...

mysql insert data from multiple select queries

What I've got working and it's what I need to improve on: INSERT form_data (id,data_id, email) SELECT '',fk_form_joiner_id AS data_id , value AS email FROM wp_contactform_submit_data WHERE form_key='your-email' This just gets the emails, now this is great, but not enough as I have a good few different values of ...

Where Is The MYSQL Settings File Located On A Windows Installation

I need to set "lower_case_table_names", but I don't have any idea where to start. I'm using XAMPP and I don't know where to look for the file or that the exact name of the file is. One source said my.cnf another said my.conf, but neither of those files exist on my drive. Is it possible I need to create such a file? And if so, what fo...

What's wrong with this inner query (MySQL)...

...besides the fact that I am a total amateur? My table is set up like this: CREATE TABLE `messages` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `patient_id` int(6) unsigned NOT NULL, `message` varchar(255) NOT NULL, `savedate` int(10) unsigned NOT NULL, `senddate` int(10) unsigned NOT NULL, `SmsSid` varchar(40) NOT NULL COMM...

Best Practice setting up PHP mysql connection

I was wondering if there's a common best practice for setting up a mysql connection object in a php program so that you don't write redundant connection code over and over in your classes. ...

PHP URL Security Question

I want to have users store the url in my database I'm using php mysql and htmlpurifier I was wondering if the following code was a good way to filter out bad data before I store it in the database? Here is the Partial PHP code. $url = mysqli_real_escape_string($mysqli, $purifier->purify(htmlspecialchars(strip_tags($_POST['url']))); ...

Python equivalent of mysql_real_escape_string, for getting strings safely into MySQL?

Hi all Is there a Python equivalent of PHP's mysql_real_escape_string? I'm trying to insert some strings into a MySQL db direct from Python, and keep getting tripped up by quotes in the strings. mysql_string = "INSERT INTO candidate (name, address) VALUES " for k, v in v_dict.iteritems(): mysql_string += " ('" + v_dict['name'] ...

Is SQLlite strong enough to use as wordpress database ?

i'm just curious. so i ask this particular question about SQLite. I haven't use this type of database extensively. but care to explain what is the basic different between SQLite and Mysql ? The reason behind all of this is i just want to know whether it possible to use it to store wordpress data and act as a database ? ...

PHP and MySQL - correct way to use mysqli_real_escape_string

I was wondering if the code below is the correct way to use mysqli_real_escape_string() when storing users data in a database. Here is the PHP & MySQL code. if (mysqli_num_rows($dbc) == 0) { $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"INSERT INTO info (user_id, url) ...

MySQL Insert Statement Queue

We are building an ajax application in which a users input is submitted for processing to a php script. We are currently writing every request to a log file for tracking. I would like to move this tracking into a database table but I do not want to run a insert statement after request. What I would like to do is set up a 'queue' of trans...

MySQL Trigger creation

I have an application where I need to INSERT an auto_increment value from a PK in another table. I know how to do this in PHP, but I need to have this done at the DB level, since I cannot change the program logic. I am new to triggers, so I'm sure this will be an easy answer for someone. Here is what I have so far: DELIMITER // ...

mysql-python stopped working

This is a rather dumb question but i'am looking at a bizarre situation. I am running fedora and have python 2.6.5 installed. The other day i installed MySQL-python using yum (because i do not have the setuptools module so i cannot build it from source). Anyway yesterday i wrote my entire data access layer in python and it was running f...

PHP inserting Apostrophes where it shouldn't

Hi folks Not too sure what's going on here as this doesn't seem like standard practise to me. But basically I have a basic database thingy going on that lets users submit code snippets. They can provide up to 5 tags for their submission. Now I'm still learning so please forgive me if this is obvious! Here's the PHP script that makes i...

Programmatic Equivalent Of Import in phpMyAdmin

I have a SqlDump.sql file that works just fine when I apply it using the Import feature of phpMyAdmin, however I need to be able to accomplish this programmatically. Being a noob, I tried to do something like this: $SQL=file_get_contents('SqlDump.sql'); $DB=mysqli_connect('localhost','root',''); mysqli_select_db($DB,'somedb'); if (mysq...

PHP - Drilling down Data and Looping with Loops

I'm currently having difficulty finding a way of making my loops work. I have a table of data with 15 minute values. I need the data to pull up in a few different increments $filters=Array('Yrs','Qtr','Day','60','30','15'); I think I have a way of finding out what I need to be able to drill down to but the issue I'm having is af...

Can MYSQL filter by date if date is stored as text? ex "02/10/1984"

Hello! I am trying to modify an app for a client which has already a database of over 1000 items. The dates are stored as text in the database with the format "02/10/1984". The system allows you to add and remove fields to the catalog dynamically and it also allows the advanced search to have specific fields be allowed. The problem ...

Begin Viewing Query Results Before Query Ends

OK, so say I have a table with 500K rows, then I ad-hoc query with unsupported indexing which requires a full table scan. I would like to immediately view the first rows returned while the full table scan continues. Then I want to scroll thru the next results. In the meantime, I would like to display the progress of the table scan, examp...

MySQL Table structure of thumb UP & DOWN for comments system ?

Hello, i already created a table for comments but i want to add the feature of thumb Up and Down for comments like Digg and Youtube, i use php & mysql and i'm wondering What's the best table scheme to implement that so comments with many likes will be on the top. This is my current comments table : comments(id,user,article,comment,stamp...