mysql

How can we rename the database name in MySQL 5.0

I am using MySQL 5.0. I have created a database named "accounts", but now I want to change the database name to "FinanceAccounts". How can I change the database name in MySQL 5.0? ...

Find overlapping (date/time) rows within one table

I have a table which stores in each row a meeting with start date/time and end date/time. meetingID int meetingStart datetime meetingEnd datetime Desired output: For each pair of overlapping rows I would like to output meetingID, meetingStart, meetingID, meetingEnd Whats the most efficient way to perform such a query in mysql? ...

How can i run an exe file in a specified path from VB.NET or C#.NET(windows applications)

Hi guys, First I am running the below Command "mysqldump.exe --user=root --password=root accounts>accounts.sql" in the path C:>, to take backup, but it show error message "mysqldump is not a recognized command". Then i changed the path in command prompt using the cd command to the location "C:\Program Files\MySQL\MySQL Server 5.0\bin>"...

How to install MySQL on Leopard, Mac OS X 10.5?

I followed this tutorial to the very end, then found out it didn't work right. I think I have everything installed but when I type mysql -uroot I only get -bash: mysql: command not found Note: I did not skip the "Setting the Path" step. Upon running this command for the first time: mate ~/.bash_login This brought up an empty fil...

SQL - Using datediff in my SQL statement

This is my SQL statement that works using datediff.............. SELECT SUM(b134_nettpay) AS Total, b134_rmcid, b134_recdate FROM B134HREC WHERE datediff (dd, '2006-05-05', getdate()) > 90 GROUP BY b134_rmcid, b134_recdate ORDER BY b134_recdate DESC, b134_rmcid I need to Replace the Hardcoded date '2006-05-05' with MAX(b134_recdat...

MySQL query to extract first word from a field

Hi, I would like to run a query that returns the first word only from a particular field, this field has multiple words separated by spaces, I assume I may need to carry out some regex work to accomplish this? I know how to do this using a few ways in PHP but this would best be carried out on the database side. Any ideas much appreciate...

How to insert into specific row in database?

Okay, so my database is as follows by this order: id (primary - auto_increment), username (unique), password, fname, mail I have it so that users register a username and password and it adds it to the database, first of all. No username can be the same, and when it does add the data to the database it auto increments the ID. All of tha...

Multiple mysqli connection problems

I am having some strange issues with mysqli connections. I was working on a page with mysqli, and it has been working fine all day. I then made a copy of this page, and stripped it down to debug a problem, and tested it as a different file. It worked fine connection wise. Upon trying to request the original file I was working on, I get ...

Make a application retrieve data from MySQL database.

I'm looking to make a application that shows something from a MySQL data base. They should go in Order according to which ever one is next. The user would set a time that the events should happen, along with a Name for it. Then, that information would go intoa a MySQL database and it will be shown along with the other events in the appli...

Select rows that contain more than one condition simultaneously...

I have table structure like this: ID cond 1 5 1 2 1 6 8 2 9 1 9 5 When I want to select rows that contain one or more conditions i use OR (...WHEN cond=2 OR cond=6 GROUP BY ID...) But how to select rows that contain more than one condition simultaneously grouped by ID? E.g. when i want to find rows that contain co...

How do I UPDATE a row in a table or INSERT it if it doesn't exist?

I have the following table of counters: CREATE TABLE cache ( key text PRIMARY KEY, generation int ); I would like to increment one of the counters, or set it to zero if the corresponding row doesn't exist yet. Is there a way to do this without concurrency issues in standard SQL? The operation is sometimes part of a transaction...

When and How to use Multiple MySQL Queries with PHP (PDO)

What are the benefits of using multiple MySQL queries in a statement, other than to minimize code. How do you execute, retrieve, and display the results of multiple MySQL queries sent in one statement using PHP (and preferably PDO). ...

MySQL logical operators

Given the query 'SELECT foo FROM bar WHERE a = x AND b = y OR c = z', how does it parse this query? (a = x AND b = y) OR c = z? a = x AND (b = y OR c = z)? That is a simple example, but what about if you're mixing and matching AND / OR with even more search terms? ...

Troubleshooting PDO: Error not caught when executing prepared statement

I have run into a problem using pdo because an error was not caught. The code is simple and works just fine, I´ll just include a sample to avoid confusion: $sql = 'INSERT INTO somedatetable (something) VALUES (:something) ON DUPLICATE KEY UPDATE something=:something' try { $stmt = $dbh->prepare($sql); $values = ...

Multiple totals out of sql

I have the code below $sql = "SELECT date1, date2, userid, jobid, result, price, total, (SELECT distinct SUM(total1) FROM Jobs) as total2 FROM Jobs WHERE total ...

Rails join table renders bad sql

UPDATED: to include model relationships I have a many to many join table between Bands and Events (an event has many bands, a band has many events...) I have a main page that lists all events, and a recent page which displays events updated in the past 7 days. Could someone explain why the recent method generates perfect sql with all ...

Selecting rows based on date and other tables

I have three tables: computers, which has columns for id, serial number, make, model, etc users, which has columns for id, real name computer_usage, which has columns id, computer_id, user_id, start_date, end_date The database records all computers that we have, our users, and who used what computer when. I want to run a query that ...

Database Design - Best way to show available hours?

I am interested in seeing suggestions for a database design regarding business hours. It would be quite similar to what Facebook has - I have a list of businesses, and I would like for users to be able to input multiple sets of available hours for that business. e.g., Monday: open 9-5; Tuesday: open 9-12; 1-5; etc. I would not like ...

ColdFusion URL property returns button name instead of the required field (ID)

I am trying to create a page that lets a user delete an image if he is logged in. I pass the image ID through the URL when the button is clicked. The problem is it does catch the image ID but when I click delete it passes the value of the button to the URL instead of the image ID. It looks like user_acc_images.cfm?delete=Delete instead o...

Using multiple datareader in VB.NET 2005 or C#.NET 2005 with MySQL 5.0 as back end

Hi guys, I am using MySQL 5.0 as back end. I am using MySqlData.dll in my project. When i am trying to execute the following code, Try Dim cnData As New MySql.Data.MySqlClient.MySqlConnection Dim lcmd, lcmd1 As New MySql.Data.MySqlClient.MySqlCommand Dim ldr, ldr1 As MySql.Data.MySqlClient.My...