With MySQL
a DIV b
is much faster than
FLOOR(a / b).
But I need to round up so I'm using,
CEIL(a / b)
It seems strange that there wouldn't be a ceiling version of DIV, but I can't find it. Is there anything undocumented hidden away somewhere? Or any other non floating point way to do this?
...
When you have 5 dropdowns for date selection (Y, m,d, H,i) how do you insert the selected date and time into a single column of a mySQL table as a datetime using PHP5?
I know they need to be combined in a string such as:
$DateTime="$Year-$Month-$Day $Hour:$Minute:00";
and then maybe use strtotime:
$Date=date('Y-m-d H:i:s', strtotime...
Can I name a column name in my mysql tables?
...
I want a trigger to fire only when UPDATEs are user-initiated (not me running updates from the MySQL command line).
What's the 'industry standard' for achieving this? I have been trying unsuccessfully to detect a variable passed in with the query (i.e. @user_update=true), but without success. A colleague of mine suggested a way to do i...
Hi all,
I'm trying to get some more info on a question I posed on another thread
Basically, I am using this method to pass parameters to a php script which returns values from a server:
NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.yourserver.com/yourphp.php?param=%d", paramVal];
NSURL *url = [[NSURL alloc] initWithS...
I have a table where I'm inserting, for instance, images and the names of the colors found in said images. The color string looks something like "white, yellow, orange, black".
Since I have a lot of these, the 50% threshold is starting to drop off some colors, since they appear on most of the rows.
The whole point of the table is to be...
Using PHP and MySQL, I want to query a table of postings my users have made to find the person who has posted the most entries.
What would be the correct query for this?
Sample table structure:
[id] [UserID]
1 johnnietheblack
2 johnnietheblack
3 dannyrottenegg
4 marywhite
5 marywhite
6 johnnietheblack
I woul...
I have 1 table filled with articles. For the purpose of this post, lets just say it has 4 fields. story_id, story_title, story_numyes, story_numno
Each article can be voted YES or NO. I store every rating in another table, which contains 3 fields: vote_storyid, vote_date (as a timestamp), vote_code (1 = yes, 0 = no).
So when somebody v...
I am using Access 2007 and have some linked tables to a mySQL database. I am using DAO to insert a record into a mySQL linked table and trying to retrieve the inserted PK using Select @@identity, but that select is returning 0.
Dim sql As String
Dim oDB As Database
Set oDB = CurrentDb
sql = "INSERT INTO Quotes ( CustomerID )...
I've heard that MyISAM tables can become corrupt, what sort of actions are most likely to corrupt them and how can you safely fix said corruptions.
...
I'm using a trigger to store changes in an audit table, I only want to store the values from columns that have been changed.
BEGIN
IF NEW.history_of_repair_trigger_fired = 1 THEN
INSERT INTO history_of_repair SET
edit_date_time=NEW.last_edited_date_time,
edited_by=NEW.edited_by,
repair_id=NEW.repair_id,
tenant_name=NEW.tenant_name,
prop...
Hi,
I'm going to build a book store in which we have 3 entities(classes): Seller,Buyer,Book. I've designed the database as the following details:
- Both buyer and seller can buy/sell one or more books respectively.
- A buyer needs a seller account if he/she wants to sell a book.
- Buyers will offer their price and seller would like to se...
Here's an excerpt of my current database (changed the table-names for an easier understanding):
Pet(ownerFK, id, name, age)
Owner(id, name)
Where id is always a surrogate key, created with auto_increment.
I want to have the surrogate key Pet.id to be "scoped" by Pet.ownerFK or in otherwords, have a composite key [ownerFk, id] as my m...
We host a service (servlet running on jboss), which receives something like 5-6 requests per second. Every request needs to connect to mysql through hibernate. Most of our requests do selects, with an insert/update every 5th/6th request. The hibernate mysql connection gets timed out after mysql connection time out period (8 hours). Even...
Is there any way to enumerate tables used in mysql query?
Lets say I have query :
SELECT * FROM db_people.people_facts pf
INNER JOIN db_system.connections sm ON sm.source_id = pf.object_id
INNER JOIN db_people.people p ON sm.target_id = p.object_id
ORDER BY pf.object_id DESC
And i want in return array:
$tables = array(
[0] => 'db...
Hi, I have a MySQL table with an auto increment primary keys... I deleted some rows in the middle of the table. Now I have, for example, something like this in the ID column: 12, 13, 14, 19, 20... I deleted the 15, 16, 18 and 19 rows.... I want to reassing/reset/reorder the primary keys so I have continuity... make the 19 a 15, the 20 a ...
I have a table called 'movie2person' with 3 columns: movieID, personID and role. I use this table to connect betwen the 'movies' table and the 'persons' table... many-to-many relationship..
I have selected movieID and personID both as primary keys...
The problem is that sometimes I need to enter the same personID for the same movieID se...
I am trying to find a record in the database that has the lowest value of its datetime column. In simpler words, I want to find a record with the earliest time.
I can use minimum to find the lowest value, but that will only return the value itself, and not the whole record.
I suppose I could create another query, but I'm wondering if t...
Have a huge mysql table with like 300,000 records and wanted to page the records in PHP (not the point here though) with a query in this manner:
SELECT * FROM `table` LIMIT 250000, 100
It could be majorly slow in the latter part of the records, especially when near the end of the table (LIMIT start very large). My guess is MySQL has t...
I have this query and I need to include another join on a table called "likes" where updates.id = likes.update_id. There will be 0 or more matches on this join.
"SELECT * FROM users
INNER JOIN updates ON users.remote_id=updates.owner_id
ORDER BY updates.status_time DESC LIMIT 50"
This is probably fairly simple, but I haven't been a...