mysql

Multiplying a whole column's entries in mysql

Hi I have 15 rows of data (user entries), each with 100 fields (answers to a survey via a radio button 1-6). Every answer from every respondent needs to be multiplied by either a factor of +1 or -1 From here I need the new positive or negative value to reside in the same table (or a new copy it doesn't really matter) Question: What's ...

Hoax LIMIT value

Is there a value that used with a LIMIT clause means nothing or no limit? I'd expected that 0 would be that value but it obviously isn't: SELECT * FROM items LIMIT 0 -- returns 0 rows ...

sql syntax problem

hello.. is there something wrong with this syntax? SELECT * FROM tblcustomer WHERE uName LIKE '%%' AND tMonth = '3' ORDER BY uName ASC i got this error.. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given.. EDIT include 'settings.php'; $con = connectDB(); $mo = array('Jan','Feb','Mar','Apr','May','Jun'...

How do I search and replace using regex in MySQL?

I'm trying to update a field which contains HTML and I want to find all the rows that have forms in them and remove the form tags and anything in between them, however I'm running into problems with my select and the regex. SELECT * FROM db.table WHERE body REGEXP "<form[^>].+?>.+?</form>"; and the error I get says: 'repetition-operat...

Query returned as Boolean?

Can't figure out whats wrong with this. $replies_sql = "SELECT COUNT(*) AS total FROM forum_posts WHERE forum_posts.thread_id = 1"; I'm trying to calculate the total replies in a specific thread. I am just testing on thread_id 1 at the moment. Error: Warning: mysqli_fetch_assoc() expects paramet...

How to Collapse MySQL Rows to Columns Result

There's a query where I want to get the: Username of the user attached to the current opportunity record Sales Stage associated with each opportunity record Dollar amount associated with opportunity record I want to: Take the current IF STATEMENT result, and collapse it Current Query: $sql = "SELECT u.user_name as USER, ...

Optimization of SQL Select for enumerators

How can this query be optimized for enumerators: SELECT * FROM Customers Table Customers customerId int - has index on it customerName, etc SqlReader that returns a set customers will be read on-demand in an enumerator fashion. While it can return huge datasets that can be read/consumed slowly in a foreach loop, every other query on ...

NULL in query values resulting in 0.00 in MySQL

I have a query that's written dynamically (OO PHP via Joomla) to insert some values into a MySQL database. The form that a user fills out has a field on it for dollar amount, and if they leave that blank I want the value going into the system to be NULL. I've written out the query to the error log as it's running; this is what the query ...

How can I create a TABLE if and only if it does not exist?

I'm trying conn = MySQLdb.connect (host = "localhost", user = "username", passwd = "password", db = "my_db") cursor = conn.cursor () q = """IF NOT EXISTS CREATE TABLE %s ( course VARCHAR(15), student VARCHAR(15), teacher VARCHA...

[MySQL] SELECT query is slow (no index needed), why is it so slow?

I have a table with over 1 million entries. The problem is with the speed of the SELECT queries. This one is very fast: SELECT * FROM tmp_pages_data WHERE site_id = 14294 Showing rows 0 - 29 (1,273,042 total, Query took 0.0009 sec) And this one is very slow: SELECT * FROM tmp_pages_data WHERE page_status = 0 Showing rows...

I seem to 'break' my mysql client when I type in a Postgres command. Any ideas how to undo this ?

Note: I'm using a bash shell on a nearly-fresh osx 10.6 install. This doesn't seem to happen to a friend who is on zsh I'm used to Postgres, so I often instinctually type \d tablename instead of desc tablename ; When I do this, the mysql client is not very happy mysql> \d items mysql> ; -> desc items; ERROR 1064 (42000): Yo...

Compatible boolean data type of various relational databases

I am trying to create a select statement that is compatible with all major relational databases (MySQL, PostgreSQL, Derby, SQLite, ...). Here the simple select statement: SELECT * FROM taggings WHERE public IS TRUE The problem is that SQLite for example does not support the boolean data type, so I rewrote my statement to: SELECT * FROM...

MySql calling stored function from within a stored procedure causing error

I'm getting a 1064 error when trying to call a stored function from within a stored procedure. It only happens on the line where I try to do this: SET account_id = get_account_id(user);. What is the problem and how can I fix it? Account ID Stored Functions: CREATE DEFINER=`aaron`@`%` FUNCTION `get_account_id`(user VARCHAR(255)) RETUR...

ordering mysql rows from derived columns?

i wanted to retrieve rows from the mysql database and order them by votes: votes_up + votes_down = votes table: posts{id, post_text, votes_up, votes_down, date} ORDER BY votes ...

What does the number in parenthesis really mean?

I always thought that the number in the parenthesis represented the field lenght? However, I understand that is not always the case. Maybe it's a mysql issue? Someone told me if I set a field to 9 characters long, I can add a value that's more than 9 characters but only the first 9 will be saved. Example ... create table "person" ( id ...

populate select box with mysql data

Hi, I have some trouble with this. I have one database with the following tables: Countries -> All countries of the world are added Cities -> The cities are also added user_profile -> The profile of the user with the fields "country" & "city". Everything works fine, even the populating of the boxes is working. But I don't know how to ...

Pick another RDBMS

Other then Oracle, MySQL, and PostgreSQL, what is out there? Is there anything else used in a production environment? By production I mean it's used to support an active project or application and not an unstable system. I'm curious about other database systems (aside from NoSQL) that are applicable for use. Looking at the feature set ...

How can I sync my MSSQL database to MySQL?

I am using MSSQL as my transactional database. This database has 200+ tables with about 25 tables that hold 1M plus records. I want to replicate the data with the same structure into a MySql database for reporting. Is there a tool or method that can do this in a fairly real time manner? ...

Adding Seconds to datetime in MySQL

I'm trying to add seconds to a date based on certain events that occur. Often times, if these events occur at the same time, too many seconds get added on. Here's how I am currently doing it in PHP and MySQL $time_add_on = 15 - $seconds_left; DATE_ADD(STR_TO_DATE(end_dt,'%Y-%m-%d %H:%i:%s'), INTERVAL '".$time_add_on."' SECOND What t...

UPDATE query with prepared statements

Having problems with and update query i keep getting Warning: Crud::update() [crud.update]: Property access is not allowed yet in crud.php on line 60 This is my code $stmt = $this->mysql->prepare('UPDATE links SET title = ?, url = ?, comment = ? WHERE id = ?'); $stmt->bind_param('sssi',$title,$url,$comment,$id); $stmt->execute(); ...