mysql

MySql User Defined Variable

How to use the user defined variable in a way that the value of the variable is reused in the subsequent query in mysql? ...

How to set binary data using setBlob() in C++ connector

I know this has been asked before, and I tried to implement the solution, but I just get exception errors when I call ps->executeUpdate(). Has anyone got an explicit example? ...

php5 and mysql5 on windows server

Hi I have installed php5 and mysql5 on my server , I can login to mysql from command, but when I try to connect using php I got this error message: Access denied for user 'root'@'localhost' (using password: YES)PHP Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\Hosting...

MySQL alternate row selects

Lets say I have data in two tables. In one I have Order ID and Order Date. In the other I have Order ID, Description and Value. I know how to do simple SELECTs but what would I use to output something like this? Order ID | Order Date | Description | Value 1234 | 10/07/2009 | | ...

How to store an IP in mySQL

strong textWe've got a healthy debate going on in the office this week. We're creating a Db to store proxy information, for the most part we have the schema worked out except for how we should store IPs. One camp wants to use 4 smallints, one for each octet and the other wants to use a 1 big int,INET_ATON. These tables are going to be h...

MySQL table -> Can you return the same row multiple times, in the same query??

SELECT * FROM menu WHERE item_id = 1 OR item_id = 2 OR item_id = 3; The above statement returns 3 rows. But the statement below only returns 2 rows. SELECT * FROM menu WHERE item_id = 1 OR item_id = 1 OR item_id = 2; And I understand why like, but is there a way to force item_id 1 to be returned twice??? Example of what I want to b...

Insert 'even numbered' rows into an existing table in mysql

I have a table: +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | fooID | int(11) | NO | PRI | NULL | auto_increment | | fooDetails | varcha...

Construct a valid MySQL query using Ruby/MySQL

If using the Ruby/MSQL library I returned an object of type Mysql::Result, how would I construct a string that loops through the object and constructs a valid MySQL query? I am having trouble figuring out how to drop the final comma from the output below, and how to pass this output back to the query() method. require 'mysql' dbh = Mysq...

Question with sending an array from PHP to GWT

Hey everyone, I am using a RequestBuilder in GWT (1.6) that successfully sends a String (formatted as a date) to a PHP script on my web server. My PHP then uses that String to query a MySQL Database. I am then able to echo a result, which is successfully interpreted by GWT. My issue is that I don't just want to "echo" back a String. I ...

How to get an array of table names in ruby

I'm trying to get the output of the query 'SHOW TABLES FROM database_name' into an array using the ActiveRecord database connection. I can't seem to figure out how to do this. can someone please enlighten me? -C ...

Excel to .csv problem

I have an excel file that i need to get into CSV. I export it fine but when I go to import it into a mysql db via phpMyAdmin i get a "Invalid field count in CSV input on line 1.". Problem seems to be that the fields are not enclosed by double quotes. I just migrated to MS Excel 2007 and am not sure how to manipulate the CSV save option...

Can I use MySQL to join two tables based on relationships with a third table?

Let's say you have three tables named Item, Event, and Seat, constructed as such: Item Id (int) Event_id (int) Section (int) Event Id (int) Venue_id (int) Configuration (int) Seat Id (int) Venue_id (int) Configuration (int) Section (int) Face_value (int) I'm trying to construct a MySQL query that pulls all entries from the Item table...

MySql - Count unique from colum

Hi, I have a mysql 'cities' table with data as follows: id name ascii_name 1 Abilene, Texas Abilene-Texas 2 Akron, Ohio Akron-Ohio 3 Albuquerque, New-Mexico Albuquerque-New-Mexico 4 Alexandria, Virginia ...

MySQL - Disabling the query output and showing only the total execution time taken

I have a stored procedure which I want to test for speed in a production environment. So I created a new stored procedure which calls this for a 100 times, each time with different parameters. My question is: how can I disable the output that the MySQL command line prints as I am sure that this adds to the total time. So, to recap, from ...

Are there any real benefits to using a RDBMS vs. flat files on a simple Web doc system (or basic CMS)?

The Project I've been asked to work on an interesting project -- what amounts to a basic Web CMS -- that uses HTML/CSS/jQuery with PHP. However, one requirement is that there won't be a database to house the data (they want flat files for the documents/pages -- preferable in JSON format). In a very basic sense, it'll be used to genera...

Mac OSX MySQL Update Stored Procedure

Good afternoon, I am attempting to run a stored procedure that updates records in MySQL 5.1 on Mac OSX 10.4.11. Here is a sample procedure: DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `TestUpd`() BEGIN UPDATE Addr SET eMail2 = 'test'; END $$ When I execute this procedure, I get the error, 'Error executing SQL ...

How to improve the following code in PHP

Hello Here is a simple form I am using to send XML data in admin_xml.php <form name="review" action="admin_xml.php" method="post"> <textarea name="xml" cols="40" rows="10"></textarea> <input class="submit" type="submit" value="Submit Request"> </form> Here is the XML which I enter in order to retrieve the data from MySQL Databa...

Is there a faster way to load mysqldumps?

mysqldump is reasonably fast, but dumps of a medium-sized database (20-30 megs) take several minutes to load using mysql my_database < my_dump_file.sql Are there some mysql settings I can tune to speed up the load? Is there a better way to load saved data? I've experimented using the mysqlimport utility with CSV-based dumps. These loa...

Formating multiple mySQL date fields at the same time

I have a table with 12 timestamp columns and 3 other fields. I can't change the field type on the timestamp columns. I need to display all 15 fields to the user as m/d/y. Is there a way to format them all at the same time without having to apply DATE_FORMAT to each one? I'd rather not have to do SELECT DATE_FORMAT(field, '%c/%e/%y...

Log killed queries in MySQL

I have some strange bug into a application(or is it the MySQL build?) that causes queries to remain in "locked" state forever, filling up the max number of threads. I read about setting the wait_timeout variable to kill the "bogus" threads after a period of time. This works ok, but I would like to log the killed queries for further insp...