mysql

how to display a particular field first and remaining next in MYSQL

I have a table structure like : ID, Test_ID, Verdict, PATH, Last_Status, Present_status, Remote_location,TestCase I want the result to be displayed starting with TestCase But I do not want to mention all the fileds particularly. Is there anything like select TestCase,* from Table order by TestCase` ? Basically the result sho...

mysql birthday reminder, leap year

Hi, I'm trying to sort out a result set that gives the 5 closest users sorted by upcoming birthday. This works perfectly until leap years comes into play. For example: May 15th - 96 days left May 15th - 97 days left The top result is a birth at 1987 and the lower is from 1988. u_birth is stored as yyyy-mm-dd. Is there a simple way to...

mysql conditional insert on duplicate update - multiple records

How can I use the ON DUPLICATE UPDATE with a multiple value INSERT? INSERT INTO tbl_name (key_id,field1,filed2) VALUES (1,2,3), (1,5,6), (1,8,9); ...

Have some questions about web development (PHP and MySQL).

I've done a bit of web programming (using PHP and MySQL), but nothing too large in scale. I've been thinking about how someone would create a social networking type of site and I've ran into some problems. How would you safely and securely store passwords in MySQL? What kinds of encryption would you use? If users were allowed to upload...

MySQL: Can I constraint column values in one table to values in a column in another table, by DB design only?

Example: Table "persons", Column "surname" may only contain values predefined in Table "names", Column "surnames", which would contain a collection of surnames acceptable for the purpose. Can I achieve this by design (i.e. without involving any validation code)? On a MyISAM table? No? On InnoDB? Thank you. ...

List all tables containing a given column name

How do a I list all tables containing a given column name? I'm using Mysql version 4.1.13-nt-log. I know versions less than 5 dont have an information_scheme DB. ...

Return the nth record from MySQL query

I am looking to return the 2nd, or 3rd, or 4th record from a MySQL query (based on a query by ID ascending) The problem being, I won't know the ID, only that it is the 3rd row in the query. ...

How can I match "laptop" and "laptops" when search for "laptop" is performed using MySQL's match...against full-text search?

I'm trying to build a search feature in to my website. Searching is the primary purpose of the site and I am having a few issues with the MySQL search feature. I would like to be able to search with a single search string against multiple text fields. I'm using MySQL's match...against statements to perform a full-text search. I'm runni...

Detecting exploits in web applications and how to proceed

What ways are there for detecting exploits in PHP/MySQL web applications (checking for certain characters or pieces of codes in the GET, POST, COOKIE arrays / using a library with a database that has all the patterns for common exploits, if any exist?) and how should I proceed when one is detected? For example, if someone tried to find ...

mysql amount of data per table

Hi: I'm designing a system, and by going deep into numbers, I realize that it could reach a point where there could be a table with 54,240,211,584 records/year (approximately). WOW!!!! So, I brook it down & down to 73,271,952 records/year (approximately). I got the numbers by making some excel running on what would happen if: a) no su...

CRUD Admins: Why not use MySQL users for auth/acl instead of User/Group tables?

In several frameworks (symfony/Django), you have admin generators that usually control access via a User table (which assigns a user to a specified Group table). I'm curious, why not simply use MySQL's actual users (with select/read/write access already baked in) instead? ...

MySQL Query - help with selection

What I'm trying is to get all users that don't have a value set for fid = 13 or no value at all in profile_values. I'm guessing this have an easy solution, ...but I just don't see it. Any help or a point in the right direction is greatly appreciated. (The tables users and profile_values are both from Drupal.) Simplified values: uid ...

Grouping items from mysql by the day they were posted

So, I'm having a problem building a feed-style list of posts efficiently using PHP and Mysql. I want to output the posts organized and grouped by the day they were posted, showing the date as a header. For example: February 9th ----------- Posts that were posted on Feb 9th Feb 8th ----------------- Posts that were posted on the 8th ...

How to add filters to this pagination script properly?

Hello, I am currently working on this tutorial and would like to add a filter button to it. I am using jquery to make an element clickable: <p id="marketing">MARKETING</p> and the jquery for the element: // Sort content Marketing $("#pagination p").click(function () { Display_Load(); //Loading Data var ...

need to print labels from a ecommerce website

Im a wiz with php but i have a challenging client- who wants sandwich labels printed automatically as they are ordered from their website. what is the best solution for this- the e-commerce website is a php/mysql website i can do a call to some sort of service running but i have no idea how to print the info? what hardware is required.....

Error message in python-mysql cursor: 1054 unknown column "x" in 'field list'

Hi there everyone, This is my first post! I also just started programming, so please bear with me! I am trying to load a bunch of .csv files into a database, in order to later perform various reports on the data. I started off by creating a few tables in mysql with matching field names and data types to what will be loaded into the ta...

Comparing 2700+ filenames against 29000+ rows in a db table (PHP/FTP/MySQL)

I have a ftp repository that is currently at 2761 files (PDF files). I have a MySQL table (a list of those files) that's actually at 29k+ files (it hasn't been parsed since a recent upgrade). I'd like to provide admins with a one-click script that will do the following: 1) Compare the "existing" filenames with the rows in the database ...

Mysql cut string, the first character?

Hi is it possible to cut string like this: String in "data" columns: ,123,456 Cut the first character i.e "," (comma). So the query is something like: Update users set data = cut first string... ...

Optimising a haversine formula SQL call in PHP

I'm creating an MySQL call using PHP, I'm calculating distance using the haversine forumula: SELECT name, id, (6371 * acos(cos(radians(' . $lat . ')) * cos(radians(geoname.latitude)) * cos(radians(geoname.longitude) - radians(' . $lon . ')) + sin(radians(' . $lat . ')) * sin(radians(geoname.latitude)))) AS distance ...

Too many connections to DB preventing some queries from executing.

I have an issue where users on my web site have recently begun to receive the error message: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) I know that the connection strings in the code are correct, as users are able to query the database view pages that retrieve info from and submit user-generated...