mysql

php mysql display by views

hey, thanks for loking. i have 3 tables books, book_category, book_click. books table book_id, url, title, img, short_desc, featured, enable book_category table book_id, category_id book_clicks table site_id, time, views i like to get data from books table by view SUMS but this only returns one result SELECT books.book_id, url, ...

Importing .XLS file data to mySQL table

How do I import data from a XLS file into a mySQL database? ...

CSV Export Script only generates error in IE?

I have a CSV export script (enrdata_arch.php) which calls information from an existing database and exports it into CSV format. For some reason however, the script returns the following error ONLY in Internet Explorer: Microsoft Office Excel cannot access the file 'https://www.domain.com/admin/enrdata_arch.php'. There are several possib...

Model Database class required (PHP/MySQL)

Hi, I'm after a model-based database class for PHP/MySQL. But it must have one particular functionality: Once the class is initialised ( e.g $user=new User(); ) I should be able to access the attributes in the user table as follows: $user->name // returns the value of the 'name' field in the user table I should not have to define the...

How to use the eclipse Hibernate Tools with grails and MySQL

I've managed to connect from eclipse Hibernate Tools to my MySql Database used with grails, classes mapped by GORM. Now I'd like to perform HQL queries on the DB using the Hibernate Tools. However Hibernate Tools tells me for every table that it is not mapped. My question: Do I really need to write all the class mappings manually into ...

Small/efficient PHP database options

Subjective question, I know, but I am counting outgoing clicks for a very specific part of a website, and I'm simply needing to keep a tally of outgoing clicks per link and per day. I know that I could use MySQL for this, but I am wondering if there is something smaller/more-efficient for this application. I manage my own server on sli...

Python MySQL Performance: Runs fast in mysql command line, but slow with cursor.execute

I'm writing a script for exporting some data. Some details about the environment: The project is Django based I'm using raw/custom SQL for the export The database engine is MySQL. The database and code are on the same box.- Details about the SQL: A bunch of inner joins A bunch of columns selected, some with a basic multiplication ...

Java Date Format Conversion

I am currently pulling three form field inputs off the request object. The day, the month, and the year. Day would be 11 for 11th day of the month Month would be 12 for december Year would be 2010 representing this year. I need to convert this into a Java Date object, but since so much has been changed, I am not sure what the best w...

char vs tinytext

What is the difference between char and tinytext in MySQL? ...

Faster MySQL Queries?

At my work I have several tables with over 200,000 rows of data. I have to set-up some queries that look over 15,000+ at a time so sometimes I get this error: PHP Fatal error: Maximum execution time of 180 seconds exceeded So, how do I speed up faster queries? The query is like this: SELECT toemail, toname FROM email_sent W...

ActiveRecord returns data in ASCII-8Bit Under Ruby 1.9.2-rc1.

Further to the title, when loading data from ActiveRecord the encoding is always set to ASCII-8Bit in spite of my best efforts to force the encoding. I have entered as much detail as possible here to try and build a good error report someone could use to help me out! The project is using the following technologies: Padrino Framework R...

MySQL order by rand() grouped by day

Is it possible to get random items inside the same day? For example: +----+---------------------+ | id | md | +----+---------------------+ | 1 | 2010-06-27 11:26:01 | | 2 | 2010-06-27 11:28:20 | | 3 | 2010-06-27 11:29:46 | | 4 | 2010-06-27 11:30:50 | | 5 | 2010-06-27 12:20:56 | | 6 | 2010-06-...

Basic profit and loss in SQL

How would I do a basic profit and loss statement in SQL? I have a sales table with a costs field, and summing that field should show the total profit Likewise I have a purchases table with a cost field, which should show the total money going out. To show profit, would I just SUM the total costs in sales, and subtract the total costs ...

How to restrict access to web application to one machine only?

I need to make sure that every users accessing my web application can do that from one machine only, so 100 users would mean 100 machines. What would be the best solution? Is detecting and storing IP during first login good idea? I think IP might change even during lifetime of the session is that right? I was also thinking of storing coo...

categories and items 1 big array

I've made some search on the forum without any good answers for my problem. If I missed something, feel free to link me to the question! What I need to do is simple: a function that returns an array of the full tree of my categories and items. I only have 1 depth (item and a cat_id), so no recursion involved (though if you have a recurs...

Slow query for update/delete sql statements

In mysql there are lot of slow queries, only related to update and delete statements. The tables have 2 index columns and not heavily indexed tables. Each table having 30K records on average. Please give your suggestions on how to overcome the slow queries related to update and delete queries. These kind of queries: DELETE FROM <table...

Wordpress latest Posts AND comments feed?

I'm trying to write a custom SQL query that will create a list of the most recent Posts AND comments and I'm having trouble visualizing how i can do this. I can pull the latest comments by date DESC and i can pull the latest posts by date DESC but how do I make a feed / query to show them both? Here is my comment SQL SELECT comment_i...

MySQL: latest comments on each post

Having the classic "posts table, and comments table with foreign key to posts table" scenario, what's the most efficient way to get the IDs of the last 20 posts ordered by the time of their last comment, and the actual comment itself? Here is a query that works but can probably be done much more efficiently: SELECT * FROM ( SELECT *...

Help with MYSQL query

Here are two overly simplified version of 2 tables I'm using: A: +-------+-----------------------+ | id | photo_id | color | +-------+-----------------------+ | 1 | 100 | red | | 2 | 101 | blue | | 3 | 102 | green | +-------+-----------------------+ B: +-------+--------------------...

'group by' works on MySQL, but not Oracle

Hi - I have a query that works on MySQL but doesn't work on Oracle, and I'm trying to convert. This is my table: unique_row_id http_session_id page_name page_hit_timestamp ---------------------------------------------------------------- 0 123456789 index.html 2010-01-20 15:00:00 1 123456789 i...