mysql

finding the last consecutive row

I need some help with a query. I have this simple table: CREATE TABLE `consecutiv` ( `id` int(11) NOT NULL auto_increment, `readVal` int(11) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1; insert into `consecutiv`(`id`,`readVal`) values (1,2),(2,2),(3,2),(5,3),(6,3),(7,3),(8,3),(9,...

can i redesign this mysql table

see my last posts http://stackoverflow.com/questions/3085796/help-me-in-mysql-query http://stackoverflow.com/questions/3079625/mysql-join-left-help Can you please tell me how can i redesign the tables? I mean which things should be changed? Also, How about if i make 2 queries like: Query 1: Select from Table one where column1 = 'smith'...

Mysql REGEXP how to do an exact match

hi, i have a notes column which contains text and has an id within the text, something like "some random text (actvityid - 1234)" i need to pull out the id 1234 in this case and update the activityid column within the same table. my query looks like this "UPDATE table_name SET activityId = {$f['activityId']} WHERE notes REGEXP '{$f['...

reduce http requests by saving images in database?

Would it make sense to improve pageload speed by serving smaller images from the database rather than make multiple HTTP requests given that the website is PHP driven? I'm thinking of smaller page design elements, buttons, thumbnails for galleries etc. ...

Does a Join table (association table) have a primary key ? many to many relationship

Does a Join table (association table) have a primary key ? many to many relationship. I've seen some Join tables with a primary key and some without can someone please explain when you would have a primary key in a join table and why? Thank you in advance;-) ...

What is the best way to store Binary data (images, pdf's, mp3's, videos ect) in mysql and why?

What is the best way to store Binary data (images, pdf's, mp3's, videos ect) in mysql and why? What i would love to know is how you do it(as developers) and why? Also how the big sites do it? Thank you in advance ;-) ...

session_set_save_handler wamp crash

Hi, I am trying to use session_set_save_handler to allow me to save sessions within a mySQL database using the code below. Everytime I try to load the page I recieve an Application Error regarding the httpd.exe, as demonstrated by the image below. http://i48.tinypic.com/2i9l2ip.jpg if I remove the following line the page works fine. ...

Printing an ER Diagram for mySQL database (800+ tables)

We have a system built by Parallels, which is relying on a huge (800+) tables to maintain everything. I need to learn this system, in order to be able to write queries to retrieve data for report generation on various needs. I am obviously, having difficulties isolating which tables are currently relevant for the task at hand, so I tho...

How can I automate server to server site transfers using PHP?

The company I work for uses two servers DEV and PROD to host its sites. DEV is obviously where we do all of our work, and PROD is where we host live sites for clients. On DEV we have created a deployment app that is used to create new sites and perform a few other administrative tasks. Right now I am looking into a way to transfer sites...

Hibernate auto increment field for multiple databases

Hello, I have a Java object with a field that needs to be auto-incremented in the database. This field is not a primary key, just a field that needs to be auto-incremented. My question is what value I need to set this field in my Java object before doing a session.save(Object)? Do I have to set it to NULL? How would the Hibernate mapp...

Weird result at selecting rows

I've been worndering why this query returns this result: SELECT direccion_principal FROM tb_dysport_contacto_medico_terapeutica WHERE direccion_principal LIKE '%Ú%' Result: +---------------------+ | direccion_principal | +---------------------+ | COLSANITAS | +---------------------+ The table collation is utf8_general_ci....

Select all months within given date span, including the ones with 0 values

Hi, I'm trying to write a MySQL query to get an average value per month, for all months between to given dates. My idea is this: Query, something like SELECT AVG(value1) as avg_value_1, AVG(value2) as avg_value_2, MONTH(save_date) as month, YEAR(save_date) as year FROM myTable WHERE save_date BETWEEN '2009-01-01' AND '2009-07-01' G...

How can I export just a single field from MySQL?

Rather than export the entire table, that is, fname, lname, address, email, etc. how can I export JUST the email field to CSV or Excel? ...

How to optimize SQL query with calculating distance by longitude and latitude ?

Hello ! I have a table with structure like that: table name: shop id_shop int(10) name varchar(200) latitude double longitude double And I'd like to calculate distance between given coordinates and coordinates saved in database. My current query: SELECT * FROM `shop` AS `s` WHERE ( ( 6371 ...

How to find if there are words repeated twice in a row

For example i have the below paragraph in a MySQL database table field "The cutting off of the illumination of an astronomical object object, as in an eclipse of the Moon, when the Earth comes between" Here the word "object" appears twice in a row (next to each other). I want to check if this case appears in other records in same tabl...

MySQL Full Text Query Locking Table

Every once in a while we get a particularly long running full text query in MySQL. The query will run for a very long time, currently I'm seeing one that's running for 50,000 seconds (and still going). Using Kill, or Kill Query on the query seems to do nothing. Also, the command Timeout on the client side is 30 seconds, so the client ...

MySQL query - Join data based on two factors, then customise the way the data is sorted based on values.

Hello, firstly I'm new to querying multiple tables so I apologise if this is a bit of a stupid question, but we all have to start somewhere! I've made a picture which should make this easier to understand: My first table wp_user has several columns - I want the values from 3 columns which are ID user_email and user_nicename. My seco...

Best Practice / Standard for storing an Address in a SQL Database

I am wondering if there is some sort of "standard" for storing US addresses in a database? It seems this is a common task, and there should be some sort of a standard. What I am looking for is a specific schema of how the database tables should work and interact, already in third normal form, including data types (MySQL). A good UML do...

Codeigniter - How to add Images to my CRUD methods?

Hi, I am working on my second CI application. I have created some simple CRUD methods in my controller. My client has requested that each record includes an image. I have searched the forums and other resources for help but haven’t had much luck. I have managed to upload files into a directory using the File Uploading Class, my problem...

Date time exception in coldfusion query in cfc and mySQL

I'm moving from an MS Access backend to mySQL. This used to work but now doesn't and I can't figure the problem. <cfargument required="false" name="expiry" type="any" default="" /> <cfquery datasource='#arguments.dsn#'> INSERT INTO users(expiry) VALUES (<cfqueryparam value="#arguments.expiry#" cf...