Questions tagged "mysql" (page No.1)

Calculating relative time

Given a specific DateTime value, how do I display relative time, like 2 hours ago 3 days ago a month ago etc...? ...

How can I restore a single column of a single MySQL table?

I have a database in which there is one table where one column has invalid data. I also have a backup of said database of a few days before. In that backup, that column still has the valid data. But other tables in that database are already incredibly outdated. So, a full ...

Produce hierarchical dataset in MySQL

I have a table of ID values of users column A has the management users and column B has the users. I want to be able to display a list of user that manage other users, for example. User 1 can manage user 2 User 1 can manage user 3 User 3 can ...

Mysql Query Divide column by 100

I have columns being stored in a table as the regular pecent significant figures as floats.(e.g 99.9) I would like to divide them by 100 so they are in they are in raw data form. (e.g) .999 What is the query I would have to write for this ...

mysql update visits=visits+1 bug

I am writing a project in MVC, when I run this query: mysql_query("UPDATE ads SET visits = visits+1 WHERE id = ".$ad->id); from: localhost/advertise/ and MySQL works fine and adds 1 to visits field, but when I am using controller and method to see the page from: localhost/advertise/index/index MySQL adds 2 to ...

Instead of using a lot of java code, why not send a script to DB in the form of text file?

I was thinking that doing java code for executing DDL, DML etc is cumbersome and involves a lot of typing. So, I was thinking if databases have/can be made to have the following feature -Take a script in a text file and execute the entire script. If we had something ...

Retrieving original timestamp after replication using triggers

Scenario is this: We have two databases db1 and db2. Statements in db1 replicate to db2. Query 1 gets executed in db1. This is replicated to db2. Upon execution of replicated query 1 in db2, a trigger needs to run in db2. This trigger needs to update a table in db2, with timestamp of when ...

MySQL vs PHP query performance issues

I have a sql query that runs in like 2 seconds in mysql (Navicat) and it runs through 600,000 locations returning all the table data and calculates the distance between a lat and long that I put in. The SQL is something like this: select *, 3959 * acos( cos( radians(37) ) ...

Yii different model value displayed in cgridview and views

I have values that are stored in raw number form percents (e.g .998) in my generated models. However, for my views, as well as display in CGRIDview I would like these data points to be multiplied by 100, but retain the same value in the backend database. So in my ...

sql query help in sorting a field that's got both string and numbers

I've got a text field called source_recid. It stores half string half number like strings in it. Example shop.orders.32442 the syntax is DATABASENAME.TABLENAME.RECID My goal is to scan this col and find out the biggest RECID ( the integer) in it. So, in a case like this shop.orders.32442 shop.orders.82000 shop.orders.34452 It would be the record whose ...

select case when not working as expected

I'm trying to understand how this works but can't figure it out yet. I have made this simple uery to test the case-when-then-end clause... SELECT case when quantity > 3 then count(*) end the_count_a, ...

MySQL how to select multiple attributes from a Cartesian product?

Ultimately, I'm trying to get multiple attributes (e.g bedrooms, bathrooms, etc) from a few tables yes I can only seem to get one attribute with my current query. What am I missing? Example tables: property -------- id 1 2 3 4 attribute --------- id name 1 bedrooms 2 bathrooms attribute_value --------------------- id attribute_id value 1 1 ...

Which one is better haversine or pythagorean?

I have mysql query to calculate distance between given longitudes and latitude within 50 meter radius. Here I want to know that by performance, speed and distance accuracy wise which one is better, haversine or pythagorean? ...

How to loop MySQL query for each row in my table?

I have a small table with ~10,000 rows with a auto-incremented ID given to them and I need to run this query per every single row in the table in a procedure. I don't understand how I'm supposed to do this.. My query: SELECT PREG_REPLACE('/_ID_[0-9]{1,9}/', '' , Stuff) FROM `thatDB`.`thatTable` INTO @fixit; UPDATE ...

why is this query not working with both dates

I have this query $query = " SELECT `code`, ...

"Solutions" for creating a DB, tables, columns and populating tables?

I want to make code that does this kind of task: check if a given database exists. 1a-->if no, then create a DB, make some tables in it and some columns too. 1.1-->Check if certain columns in a "list" exist. Create ...

PHP/PDO strange request

I want to do a PDO request that will get informations from 2 different tables, but things fastly get hard, i explain : I have a first database table (flowers) that is organized like this (but it's REALLY bigger than what I show to you) : ID; ...

MySQL Between is not grabbing the end date?

I have a query: SELECT ... FROM orders WHERE date_created BETWEEN '2012-07-30' AND '2012-07-30' It returns 0 results, although there's 1000+ entries for date 2012-07-30. I found out that the BETWEEN simply does not grab the END date, so if it was BETWEEN '2012-07-28' AND '2012-07-30' ...it should grab me entries for 28, ...

Understanding the difference between character matching and token matching

What is the difference between search features implemented using substring/character matching and search features implemented using token based matching? I'm looking for an intuitive and not-too-technical explanation for product planning purposes. Below is my explanation, is more or less correct, but not intuitive or complete. The answer has to do with ...

« Previous12345678910 ... 58535854Next »Show All