mysql

MySQL: How to search multiple tables for a string existing in any column.

How can I search for in table_a table_b table_c, which have a random number of columns for a string? I know this is not propper sql but it would be something like: SELECT * FROM users, accounts, something_else WHERE ->ANY COLUMN CONTAINS 'this_string'<- Ty in advance for SO community ...

Ensuring MySQL connection works in PHP function

I have code with the following form: <?php function doSomething{ //Do stuff with MySQL $con->tralalala(); } $con = connectToDatabase;//This would actually be a line or two. doSomething(); ?> This (type of) code doesn't work, because doSomething() doesn't have a connection to the database. Can anyone explain why not? I create the...

a "forgot user password" standard class or script in php/mysql environment?

Hi, I am hoping that there is a standard class/php script that we can use for the "forgot password" functionality. It seems almost every website has one, and I'd like to reduce the development time on it. It appears that a common approach is: 1) click on Forgot password 2) User receives via email a "reset password" link 3) Click on th...

How do you talk SQL directly to MySQL from Ruby?

I want to write a script in Ruby to clean up some messed up keys in several copies of the same MySQL schema. I'd like to do something like SHOW CREATE TABLE, then look at what comes back and delete keys if they exist. I know in the Rails environment you can do this... ActiveRecord::Base.connection.execute( some sql ) But what you get...

MySQL DATETIME question

I have a DATETIME field. I would like to select all the records that have been updated in the last week. Right now I'm using this query: SELECT SUM(mins_spent) as time_sum FROM todos WHERE lastUpdate >= '2008-12-22' AND lastUpdate <='2008-12-28' But the results i get seem to be different depending on time of the day, e.g on 7 PM I mi...

[SQL] What's the best way to get related data from their ID's in a single query?

I have a table where each row has a few fields that have ID's that relate to some other data from some other tables. Let's say it's called people, and each person has the ID of a city, state and country. So there will be three more tables, cities, states and countries where each has an ID and a name. When I'm selecting a person, what'...

What setting might be causing an AMP server to only allow 1 request at a time per browser?

I'm using an AMP server (Apache 1.3, MySQL 5.0, PHP 5.1.5) which I have found to only allow 1 connection/request per browser at one time. The easiest way to reporduce this is to request a large download which is passed through PHP and try to access another page at the same time. You will end up waiting for the first request (the file dow...

How do I solve this issue with gethostbyname_r and DBI or DBD::MySQL on FreeBSD?

I have some old perl code which recently stopped working on a FreeBSD box. The code which fails looks (in simplest form) like this: #!/usr/local/bin/perl -w use strict; use DBI; my $datasource = "DBI:mysql:dbname:hostname.domain.com"; my $user = "username"; my $pass = "password"; DBI->connect($datasource, $user, $pass); This fails...

Is it possible to decrement a variable in MySQL?

I'm wanting to decrement a variable in a MySQL table by one everytime an UPDATE query is ran. What I have is this, which isn't working: UPDATE forum SET replys = reply-- WHERE fid = '$id' Is this possible in any way, or am I going to have to run a SELECT and get the value first, decrement it, and then insert the new value into the UP...

How do I install MySQL and the python MySql package on OSX Leopard? Or how do I learn about being a web developer using OSX?

I'm new to the Mac OS and I'm just about ready to throw my brand new MacBook pro out the window. Every tutorial on setting up a Django development environment on Leopard is insidiously wrong. They are all skipping over one step, or assuming you have setup something one way, or are just assuming that I know one thing that I must not. I...

Alternatives to MySql Query Browser?

I have been using the MySql Query Browser and [opinion]it has to be the worst UI that I've seen for anything. Ever.[/opinion] But it's free, so it's great and I love it. Can anybody recommend any better, free tools for MySql DB admin? I want it to run on my local machine and not in a browser, if possible... Edit: I'm on Windows, but if...

Count occurrences of a word in a row in MySQL

I'm making a search function for my website, which finds relevant results from a database. I'm looking for a way to count occurrences of a word, but I need to ensure that there are word boundaries on both sides of the word ( so I don't end up with "triple" when I want "rip"). Does anyone have any ideas? People have misunderstood my ...

MySQL schedule conflicts

Hey, I stumbled upon this site looking for solutions for event overlaps in mySQL tables. I was SO impressed with the solution (which is helping already) I thought I'd see if I could get some more help... Okay, so Joe want's to swap shifts with someone at work. He has a court date. He goes to the shift swap form and it pull up this week'...

MySQL .Net Provider 5.2 does not show up in Data Source dialog of VS 2008 Express

Hi, I have installed MySQL .NET data provider 5.2 (through it's installer) but I could not see the MySQL data provider in Data Source dialog of Database Explorer. I am using VS 2008 Express edition. Do you have any clues ? Regards, Jatan ...

Getting a PHP DateTime object into a string representation of a MYSQL date

I have a DateTime which I want to store in a Date MySQL column. I am using MySQLi and prepared statements. When binding parameters, I cannot specify date as a type, only strings and integers. How do I convert the DateTime to a MySQL date string representation? There is very little documentation on the DateTime class. ...

Ordering by the order of values in a SQL IN() clause

I am wondering if there is away (possibly a better way) to order by the order of the values in an IN() clause. The problem is that I have 2 queries, one that gets all of the IDs and the second that retrieves all the information. The first creates the order of the IDs which I want the second to order by. The IDs are put in an IN() clause...

Should I be using PreparedStatements for all my database inserts in Java?

What is the recommended method for escaping variables before inserting them into the database in Java? As I understand, I can use PreparedStatement.setString() to escape the data, but PreparedStatement seems somewhat impractical if I don't plan to run the same query ever again.. Is there a better way to do it without preparing every que...

Setting Windows MySQL client default script folder.

From withing the MySQL client on Windows, how do I set it to point at a particular Windows folder so the file in a SOURCE statement doesn't have to include a path? ...

MySQL finding subtotals

EDIT: I'm told that making you guys read means I get less attention. My apologies. Here's a simpler version: Bill got $100 dollars worth of items from a store. He wants to return enough of the items to get exactly $30 dollars back. The store has a Point of Return system that will help him do this. Here is the data after he scans his...

Database design question

I accumulated a quite a lot of data in a raw form (csv and binary) - 4GB per day for a few months to be precise. I decided to join the civilized world and use database to access the data and I wondered what would be the correct layout; the format is quite simple: a few rows for every time tick (bid, ask, timestamp, etc.) x up to 0.5Mill...