mysql

Sql query for this?

person_id | manager_id | name | | | | ------------------------------- Query to find name of manager who supervises maximum number of employees? Added: This is the only table. Yes self-referencing. DB is mysql. Recursive queries will also do. ...

mysql: instr specify word boundaries

i want to check if a string contains a field value as a substring or not. select * from mytable where instr("mystring", column_name); but this does not search on word boundaries. select * from mytable where instr("mystring", concat('[[:<:]]',column_name,'[[:>:]]'); does not work either. how to correct this? ...

some doubts like..user.id and username(primary key function),how to allow doc file for databaee,file_exist problem

I have ten fields in my table in database..And two columns out of them are of User_Id (auto_increment I need it for uploading pics.) Username (I want it as primary key so that no other user can get the same username) I am not able to do both these things together. If I make user_id auto_increment then I am not able to assign primary...

Invalid Form Submissions-- what to do with them?

I've been doing a lot of reading lately about best practices when it comes to Web App design. My language of expertise is PHP/MySQL. When creating an MVC architecture for an application I'm developing, I always come across the problem of where to store invalid form submissions (so that the user doesn't have to re-enter the data, and help...

Returning rows that has matching record in another table.

I have Table Students with columns Student ID and Student Name. I also have Table Events with columns ID, Student ID and Event. Now, i want to write a query that will return only rows from Students Table that has its Student ID present in Events Table. I am running MySql 5+. ...

utf-8 problem in using jquery autocomplete tags

hey mates . recently i used jquery auto-complete tag http://devthought.com/projects/jquery/textboxlist/ everything goes fine except utf-8 tag suggesting , only English tags are suggested i guess something goes wrong with script lines it works fine with English tags but not with multi byte languages like Persian ...

The Integrity of linked data entities on update

What is the best-practice for maintaining the integrity of linked data entities on update? My scenario I have two entities "Client and Invoice". [client is definition and Invoice is transaction]. After issuing many invoices to the client it happens that the client information needs to be changed e.g. "his billing addres...

MySQL Ordering Results by the order of Where Clause Matched

I have a query that tokenizes a phrase on spaces and needs to look for the best match for the phrase. It needs to return that match first. I'm trying to do this in a single query using where clauses. Is this possible? I'm trying something along these lines: for: my phrase select name from myTable where name="my phrase" or name like...

mysql foreign key constraints

I have set foreign key integrity in a table. But i am able to delete data from the master table, which is reference in child table.. What would be the problem Actually it should say error on deletion like all referenced table data has to be deleted. ...

Install Mysql Gem for Ruby along with JRUBY Gem

Hi. I have Jruby gem Mysql installed on my machine. However due to some reason, I had to move to ruby instead of ruby and everything seems to be working fine except that mysql gem for ruby isn't installed and now when I try to install Mysql gem i get following error: Building native extensions. This could take a while... ERROR: Error...

Symfony i18n table: Ways to get fallback default value?

Hi, I'm building a city names table in MySQL with about 10K rows to be a Symfony i18n table. Basically, the default culture is en_US and every city in the table is initially of this culture. Over time, I'd like to add to the table only those cities that might have an alternative name in a different language, such as "London (en_US) / Lo...

Multiple database connections in Rails

I'm writing a simpler version of phpMyAdmin in Rails; this web app will run on a web server (where users will be able to indicate the database name, hostname, username, password, and port number of one of the database servers running on the same network). The user will then be connected to that machine and will be able to use the UI to a...

Creating a DAO Query with many One-to-Many Relationships?

I am developing a web application with PHP and MySQL. I have an entity named, User, that has many one-to-many relationships (with other objects) within it (list of Addresses, list of Emails, list of PhoneNumbers, etc). These many addresses, emails, phone numbers are supplied to the user via junction tables in the database (user_link_addr...

Need help with MySQL query for Wordpress

My problem is not with Wordpress's WPDB class, but with the MySQL syntax. I'm trying make the following sequence work: Get an array of all Posts IDs Filter out posts from a specific Category Filter out duplicates, revisions, drafts etc. Only show Published content. Help? Thank you. ...

PHP custom CMS and SEO

Hi All, I have a custom CMS for the performing arts center in my town about to launch. They will have artists/events/media, etc. on the site via the interface I've built for them in php/mysql. My question has to do with google indexing and the CMS content. Odds are they won't be deleting archived shows (which will have a url like s...

ruby / rails / mysql performance degraded on Snow Leopard

I've burned a bunch of hours on this. I'm not having problems getting things to build, but I am seeing that my test suite runs about 2x slower than when I was on OS X 10.5.x . I've spent a lot of time playing around with different optimization settings (learning to avoid homebrew's llvm-gcc compilation). I've just learned that I needed t...

Is it possible to create 2 fields that may NOT have the same value ?

Say I have a ticket and this ticket has an owner and a taker. The owner ID is set when the ticket is created and the taker ID is set to default to NULL. In this case the taker may NOT also be the owner. I know this is trivial to do in the progamming logic but I am wondering if it can be done in the database. Setting the two fields to u...

MySQL updating records, but page display not showing new data

I am writing an application to CRUD user details. I kick off the page with a query to the user table - and use the data to populate various form elements in the page (and to check for duplicates). All form submissions submit to the same page. Adding, deleting and modifying records work as expected - but the kicker is that the data displ...

What to do with a community URL style like Last.FM or Wikipedia?

Hi, I'm trying to understand how I should work with characters in URLs, this because I'm building a site where the user can store content and go to the content's page by digiting it's name in the URL. so, something like Wikipedia or Last.FM website. I see in the site, user can write something likehttp://it.wikipedia.org/wiki/Trentemøll...

Check load on mysql database

Hi guys, What would be the best ways to monitor mysql performance and load, queries per second, total queries over a hour etc? Thanks! ...