mysql-query

I am writting a mysql query. Help me out.

I have a typical situation. my table has four column. (id, user, col2, status) I want to write a query which gives me the results of col2. But it has a column status which has (0/1). So I want only col2 data which has 0 status + a user's all data (0/1). id user col2 status 1 sam aa 1 2 sam bb 0 3 sam cc 1 4 max dd 0...

What's the Best way to store html data in a mysql database?

Should I create a text field or a different type of field? Is there anything else I should know before writing the insertion script? ...Or the select scripts? ...

php memory_limit issue

hi, one of my script required large memory. and probably because of this I am getting following error Fatal error: Out of memory (allocated 42729472) (tried to allocate 32 bytes) I tried to change memory_limit by using ini_set('memory_limit', '256M'); on the top of my page but still I am getting same issues. I also tried ini_set...

Trying to optimise a simple SQL update statement with a subquery.

This query is very slow, taking about 1 second per record. Sadly, for (and because of) the size of the database, this is untenable as it will take days to complete. Can you suggest a way to speed it up substantially? (I only need to run it once, but in a <1hr window ideally) update participants set start_time = (select min(time_stamp) ...

How important is database normalization in a very simple database?

I am making a very simple database (mysql) with essentially two types of data, always with a 1 to 1 relationship: Events Sponsor Time (Optional) Location (City, State) Venue (Optional) Details URL Sponsors Name URL Cities will be duplicated often, but is there really much value in having a cities table for such a simple databa...

MySQL Query - Using Aggregate and Group By to generate separate results

I have a table where one or more entries with the same 'id' value can be inserted into our log / fact table (contains over 100+ million records) At a set frequency a new record is inserted into this table with a new value for the columns 'created' and 'view_percent' (percentage of a video viewed). With two different queries, I would like...

MySQL cross-database WHERE clause

I am working on a project that obtains values from many measurement stations (e.g. 50000) located all over the world. I have 2 databases, one storing information on the measurement stations, the other one storing values obtained from these stations (e.g. several million). A super-simplified version of the database structure could look li...

Query result in MySQL Console does not match the result of PHP's mysql_query()

My MySQL query returns different results depending on how the query is submitted. When the query is submitted through the MySQL Console results in. mysql> SELECT `modx`.coverage_nation.id, -> `modx`.coverage_nation.name, -> `modx`.coverage_national_region.id, -> `modx`.coverage_national_region.name -> FROM ...

Display Album with Photos (PHP)

To start off, this really isn't CodeIgniter specific. I'm having trouble grasping an idea, so anyone that knows PHP/SQL (or whatever my problem is) can jump in. I have 2 tables, 'Photo' and 'Album'. Album columns : ID TITLE USER_ID CREATED MODIFIED Photo columns : ID ALBUM_ID TITLE LOC CREATED MODIFIED I'm using the query ...

variable in MYSQL requery with REGEXP

HI, I am trying the below code . $domain = $_GET['url']; $sql = 'SELECT * FROM `domains` WHERE `domain` REGEXP CONVERT(_utf8 \'$url\' USING latin1) COLLATE latin1_swedish_ci'; $result = mysql_query($sql); while($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "id :{$row[0]} <br>"; } will get the domain from user using $_...

do you table can be as IN procedure in mysql?

do you table can be as IN procedure in mysql? ...

Select query with regular expression - MySql

I want to select records if a particular column has numbers in its name. Table 1 ID EmpCode EmpName 1 1C Name1 2 2C Name2 3 C3 Name3 4 CD Name4 5 CD Name4 6 C6D Name6 7 7CD Name7 I need to select records 1,2,3,6,7 based on EmpCode. How can this be pe...

Include table name in SQL query

What I need to do is get a table name in result from a union query with 4 selects from different tables. I need to get the id and the table name for further processing. For example i have table1, table2, table3 table4 and have a query: SELECT id from table1,blablabla UNION SELECT id from table2,blablabla UNION SELECT id from table3,bla...

SELECT MAX() function in MySQL

I'm trying to figure out a problem I'm having with a SELECT MAX() command. I want to gather the highest value in the 'BidAmount' column, but I only want selected entries to be scanned for the highest value. For example, I want the highest 'BidAmount' to be returned where another column 'UserID' = 6. I want to know the highest 'BidAmoun...

Opening one MySQL connection vs opening and closing a lot of connections?

I have a > x20000 loop in php that checks if an entry exists in a MySQL database, I open & close the connection for every entry in the loop, but a friend told me that's crazy and I should open one connection, run the loop and then close it, but he didn't tell me why. Could someone explain me the benefits of reusing the same connection? i...

Firefox showing records size as 2MB ,

Hi , Am simply executing query , The record count just 2980 , but it allocate around 2MB , I dont How its 2mb, just rendering records without css , how to track , For what reason it showing as 2MB , ...

Please help with sql query.

People help ... There are two tables: Clients idClient int login varchar Messages idMessage int dateWakeup datetime .... other fields need for each client to count the number of entries in the table Messages in a given range of time. i tried something like this: SELECT c.login, count(m.idMessage) FROM Clients c, Messages m where...

Sql Query - Unique item with latest date of entry

**Update: Title should have read: Sql Query - Unique item with latest entry Hi there, I have a two tables. users and rsvp. Users has user detail in it (id, name, email) rsvp has rsvp status in it (answerid, userid, eventid, answer) Note: answer 1 = coming answer 2 = not coming answer 3 = maybe answer 4 (pseudo answer) = no reply Plea...

i have problem in mysql

Error Code: 1109 Unknown table 'chaindb.credit_trans' in field list i have error-code 1109 in call procedure in mysql help me,please ...

zend framework: wait for query to finish before starting another

In a web app I've created in zend framework, I'm creating a new database for every new client that registers. This query of course is rather heavy and time consuming since we need to create a database, create some 10 tables and put some data in the tables. We are using one large SQL file that we read in and exec(). After those queries...