mysql

Help needed with building a mysql view

Hi all. I'm trying to build a mysql view and am struggling a little. The relationships/tables involved are: Question #fields - subject_id, privacy, keywords has_many :taggings has_many :tags, :through => :taggings has_many :gradings Tagging (polymorphic join table) #fields - taggable_type, taggable_id, tag_id Tag #fields...

MYSQL wrong time.now

Hi there, We got a Rails 3 Server based on Ruby 1.9.2 running on a MYSQL DB and Problems with the time.now and time.zone.now setting. For better explaination we assuse its 13:00 UTC right now. Ubuntu Systemtime is set to 15:00 UTC +02:00 (Thats CEST (Central European Summertime) and is correct for our Timezone). The Rails time (time....

mysql: how to write a table of views

I think my question is best explained via an example: Suppose I want to write a webserver for streaming music. I have the following columns in the songs table: |song_id|song_name|song_genre|song_length|artist I would like to enable my users to save playlists, but I don't want my playlists to be defined by explicitly specifying the songs...

server side printing to PDF (MySQL --> image --> PDF ?? ) probs with embedded 中文 Chinese

We're running PHP homegrown app on linux server with MySQL. MYSQL ---> PDF Very complex output - with English and Chinese (Simplified). We've many 'corporate' customers without CHI on their systems, and are unable to add fonts to their machines (for security reasons). We've embedded the fonts - but that makes the files HUGE (4-8M per...

mysql function to pretty print sizes (pg_size_pretty equivialent) ?

postgresql have the pg_size_pretty() convenience function: > select pg_size_pretty(100000); pg_size_pretty ---------------- 98 kB Does MySQL have something similar ? If not, before I make my own have anyone already made this, that they can share ? ...

PhpMyadmin CSV Import data order? Mine is jubmled from CSV order?

I'm trying to import my CSV data file back into my database in the same order it is in the CSv file. However when I import the order is all jumbled from how it appears in the file. Is there a way to force PHPmyadmin to import in the exact same order as the CSV? ...

getting a variable from a public scope to connect database

<?php $settings['hostname'] = '127.0.0.1'; $settings['username'] = 'root'; $settings['password'] = 'root'; $settings['database'] = 'band'; $settings['dbdriver'] = 'mysql'; /** * DATABASE */ class database { protected $settings; function __construct() { } function connect() { $this->start = new PDO( $this->settings['dbd...

fetching the current date in sql

in the databse i have the format of the date like 'yyyy-mm-dd'. how can i fetch the current date in this format? and then if i want to calculate the date after 1 week how can i do that. thanxx in advance. Using php and mysql. ...

mySQL CPU Usage 99%

We have a java based SaaS application running on mySQL database on a 2 GB Linux VPS. Recently we added RAM to the server and since couple of days, mySQL is taking up 99% of CPU usage. We are quite clueless as to why this is happening. We have made some changes in the my.cnf file as we have read in certain forums. We have enhanced the res...

mysql - Find parent with child

I have two tables parent{ parent_id } child{ child_id parent_id } I need to find a parent with parameters are children id Ex: Find a parent has exactly children (1, 2, 3) I tried "Where child_id IN (1, 2, 3)" but it will return incorrect parent in case parent has children(1, 2, 3, 4) I can hard code with php but I ask ...

Is it a good idea to use XML files to present data that is not updated often? VS MYSQL query

Hi, I'm building my website and I'd like to limit calls to my MYSQL database. One idea I have is to use XML files to present information that does not need to be updated as regularly as every page load. Two example are Site navigation which might only change once a week. The number of items in stock which will in most situations on...

mySQL show database for user

Hi all, Anyone knows the mySQL syntax to show the database names that a specific user has the privilege to see in a mySQL database? Say the user is 'dimitris' accessing a database at 'localhost', what would be the syntax to see all databases he has the privilege to select, update, insert etc? Dimitris ...

Query to count the exact number of records in all tables

IHello, I'm trying to count for each table in my MySQL database how many records there are in it. All of my tables happen to be in InnoDB and this query SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'myschema'; is way much too much of an estimate (There are +846 records and it tells me there are only +-400) ...

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '

I am trying to insert html pages to MySQL with my Asp.NET project but i am getting error; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'de Osman patlaması', '', '<div style=\"text-align: center\">\r\n<img src=\"/i' at line 1 How can i fix that p...

MySQL query, intersection on many-to-many relationship

Does someone have a good idea/solution how to achieve this? Situation is: I have the tables 'releases' and 'ntags', related via 'releases_ntags' (containing 'release_id' and 'ntag_id') And I would like to fetch results for releases via the ntag's 'slug'. I manage to have this semi-working: sql SELECT r.id, r.name FROM releases r LE...

Is there a way to make a param optional in PHP PDO?

Say I have this query: $qry = 'SELECT p.id FROM products p WHERE p.type = :type AND p.parent = :parent'; If I wanted to make "type" optional then the only way I know how to do it would be to do something like this: $qry = 'SELECT p.id FROM products p WHERE p.parent = :parent'; if(isset($type)) { $qry .= 'AND p....

MySQL latest records with condition

I need to get the latest records, which are repeated more than two times. structure: CREATE TABLE IF NOT EXISTS `tags` ( `tag_n` int(10) NOT NULL AUTO_INCREMENT, `post_n` int(10) NOT NULL, `tag` varchar(30) COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`tag_n`), KEY `tag` (`tag`), KEY `post_n` (`post_n`), ) ENGINE=MyISAM DEF...

Download mysql Table with php nusoap

I want to export/download a table from a mysql database to a txt or csv file like the way you can in phpmyadmin. The table can be anywhere from 100 - 90k entries and the mysql query will take place on a php page. ...

Seam update not working with Composite primary key.

Hi, The database i am using is Mysql and Seam 2.2.1.CR2. The table userroles has 2 columns - userid and roleid and both form a composite primary key. In code when i override the update method, it gets executed and returns the Updated status message but the database layer is not updated as no hibernate update sql is generated and nothing...

Mysql - Select words from text

Hello guys, I have a table contains 300 locations name (Pris, London,...) is there a way (query) to select locations from specified text. for example: " Transport for London (TfL) is in talks with its American, Australian and European partners about issuing a single contactless card for Paris, New York". I want a query to get: Lond...