mysql

INSERT into ENUM column

Hi, I have a ENUM column in db like so, ENUM('us','uk','fr','intl') I'm using checkboxes to confirm the country in HTML and the PHP is SET country ='".$country_us." ".$country_uk." ".$country_fr." ".$country_intl."' The query passes but it does not add to the column. If I do just country ='$country_us' -- it works fine. Here's...

Is MySQL Connector/Net backward compatible?

If I have a MySQL server 5.1, can I use all the onnectors from version 5.1 and above?: Connector/Net 6.1 Connector/Net 6.0 Connector/Net 5.2 Connector/Net 5.1 Clicking http://dev.mysql.com/downloads/connector/net/ defaults to 6.0... ...

mysql calculation

Hi all. This is my initial question....well I got a response but I'm still stuck. Can anyone please explain how can I achieve this in mysql: I have two fields in mysql, 'cap_commdate' with DATE TYPE and 'cap_policyterm' with INT TYPE. I want to have another field called 'cap_maturityDate' which will automatically compute the policy term...

WHERE statment with SET field.

Situation: Have a SET field called country with values ('us','uk','fr','intl') When I go to pull the content from the db: $sql = "SELECT id, title, content "; $sql .= "FROM table_name "; $sql .= "WHERE country='us'"; Works fine with entries labeled only 'us' but if the entry is 'us,uk' or 'us,fr,intl' and so forth. It does not ...

Programming newbie - help with designing a web app

I do a bit of HTML/CSS for fun but I am looking at picking up some programming skills. I have been reading up on PHP and MySQL. So far I have not found it too hard understanding the concepts such as loops, condition statements etc but I want to get stuck in and start developing an app before I get too bored reading and giving up comple...

Creating DATETIME from DATE and TIME

Is there way in MySQL to create DATETIME from a given attribute of type DATE and a given attribute of type TIME? ...

Help with MySQL SUM()

Here is my select query: SELECT SUM(rating) AS this_week FROM table_name WHERE UNIX_TIMESTAMP(created_at) >= UNIX_TIMESTAMP() - 604800) Which basically counts the rating of an item for the last week (604800 is a number of seconds in 1 week). The problem is that when there are no rows in the table, the this_week will be returned as ...

Group by MySQL mess

I am really having a trouble figuring this one out. I have a table 'Comments': cmt_id (primary key, auto incr), thread_id, cmt_text And I have these records in it: cmt_id thread_id cmt_txt 5002 1251035762511 Alright, I second this. 5003 1251036148894 Yet another comment. 5001 1251035762511 I am starting a ...

MySQL choking on curly (smart) quotes

I'm inserting some data into a database from a form. I'm using addslashes to escape the text (have also tried mysql_real_escape_string with the same result). Regular quotes are escaped, but some other quotes are not. For example, the string: Homer's blood becomes the secret ingredient in Moe’s new beer. is converted to: Homer\...

Deleting millions of rows in MySQL

I recently found and fixed a bug in a site I was working on that resulted in millions of duplicate rows of data in a table that will be quite large even without them (still in the millions). I can easily find these duplicate rows and can run a single delete query to kill them all. The problem is that trying to delete this many rows in on...

Getting newlines instead of slash-f-s when echoing RTF from PHP

Hi, I'm migrating a old (circa 2001) PHP 3 app to a new PHP5 server. 90% of the code worked right out of the box after migration and most of the remaining bit worked once I went through the old php.ini and changed settings in the new php.ini to match. Still there's one really annoying thing. One of the major things the app does is creat...

MySQL - return only entries from the past X days

I'm working with a database that has date information stored as a Unix timestamp ( int(11) ) and what I want to do is only return entries from the past X days, the past 90 days for example. What I've come up with is: SELECT * FROM mytable WHERE category=1 AND FROM_UNIXTIME( time ) > DATE_SUB(now(), INTERVAL 91 DAY) Where 'time' is t...

struggling with special characters (html_entity_decode, iconv, and more)

I've been struggling with getting a bunch of characters translated down to core utf-8 to store them in my database. PHP iconv fails on many characters, so i've been forced to build my own 'solution', which really isn't a solution if it doesn't work, and it fails almost completely in windows, so developing with iconv is mostly fruitless...

MySQL Multiple select

I have an indextable which hold a content_id and type colomn. (eg. content_id=1, type=audio. content_id=1, type=video) Would it be possible to get the right data based upon content_id from the right tables (tables: contentvideo, contentaudio)? ...

How do I export from MySQL to an Excel file in my PHP site?

I'm displaying a table of data: [Name] [Tel] [Email] [checkbox] Name 1 000 [email protected] Name 2 000 [email protected] (checked) Name 3 000 [email protected] (checked) (BUTTON TO DOWNLOAD CHECKED IN XLS) What I'm trying to achieve here is to create this button which will allow the user to download all checked entries in an XLS file? ...

Writing desktop app that uses database. Suggestions for how to manage user access to tables?

I'm writing a depsktop application (in Java) that interacts with a database which stores mostly requirements documents,but I have a bit of a dilemma. Specifically, a problem with managing user access. To illustrate, I store all details on the folder structures in a single table. However, I would like to institute a user-group mechanism...

Zend Framework Select Objects And UNION()

I'm pretty sure this is not possible in Zend Framework (I have searched the Web, the documentation and issue tracker) but I just want to make sure so I'm asking here. $select = $this->select(); $select->union($select1, $select2); That doesn't work of course. To explain what I need. I need to use UNION() to merge 2 tables in a SELECT q...

MySQL Date Search MM/DD/YYYY to MM/DD/YYYY

I have a table in MySQL That looks like the following: date |storenum |views ------------------------------- 08/21/2009 |42 |3 ------------------------------- 08/22/2009 |43 |1 ------------------------------- 08/21/2009 |43 |4 ------------------------------- 08/22/2009 |42 |22 ------...

MySQL need help.. how can I filter max(date)

i have a table assumed like this [table a] UID | UNAME ------------------ 001 | a 002 | b 003 | c [table b] UID | LOGS ---------------------- 001 | 2009/08/01 001 | 2009/08/03 003 | 2009/08/02 and i want to have a query like this UID | LASTLOG -------------------- 001 | 2009/08...

MySQL equivalent of ORACLES rank()

Oracle has 2 functions - rank() and dense_rank() - which i've found very useful for some applications. I am doing something in mysql now and was wondering if they have something equivalent to those? ...