sql statement help
Hello, I have a table which called people, and I have there 2 columns, name and age How can i select the names with age above 15 for example ? Thanks ...
Hello, I have a table which called people, and I have there 2 columns, name and age How can i select the names with age above 15 for example ? Thanks ...
This question is really just out of curiosity. Can someone shed some light onto why this query: insert into c ( select a.* from a,b where a.x=8 and y=1 and b.z=a.z and active > '2010-01-07 00:00:00' group by a.z ) is a million times faster (or close enough) than the query below whenever there's quite a few records involved...
I am worried this is a bit expensive. Plus I will soon implement a normalized system for the tags so there will be additional joins. On top of that I have 4 tables (tbl_videos, tbl_articles, tbl_galleries and tbl_users) of which I want to display three results of each and thus will have to run the query four times on one press of 'se...
I have a table where I want one value to be set to the same as another when inserting. Here's the table in question; CREATE TABLE categories ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(30) NOT NULL, root INT NULL DEFAULT id, PRIMARY KEY(id) ); I want the column ´root´ to get the same value as the ´id´ column gets when i...
Hello! This is my first time I am trying to make something seriously with relational db in MySQL and some kind of CMS created in PHP with CodeIgniter. I came to the part where I have to insert some data in few many-to-many related tables. In my code everything works fine (well, with just few minutes of testing), but I need some help with...
I have a products table with a column that contains a space separated list of ids (like: "23 42 365"), the column is called "categories". The numbers refer to rows ids in another table (categories). I need to extract all product rows where all of the ids in the space separated list point to rows on the categories table that no longer ex...
I'm in the early stages of my database design so nothing is final yet, and I'm using the "TOXI" 3-table design for my threads which have optional tags, but I can't help but feel that the joining is not really necessary and perhaps I need to just rely on a simple tags column in my posts table where I can just store a varchar of something ...
Is there a way to query users table like this: | id | username | ----------------- | 1 | user1 | | 2 | user2 | | 3 | user3 | and user_roles table: | id_user | id_role | --------------------- | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 | 2 | | 3 | 1 | assuming that role w...
is there any way i can group several of my columns together? in one for my scripts i need to set several of my columns to the same value, is there a better way than typing out all the column names in my update query? thanks ...
I have written a script that gets paypals current rates compared with the dollar every hour (the currency my products are in by default). The user can set their currency in their settings and that is store in the user table. My initial idea was to store all the currencies rates in the database and then when the user logs in store the c...
Hello! I'm using HeidiSQL ( http://www.heidisql.com/ ) to manage my databases at work (I prefer this over phpMyAdmin). Now, I want to use HeidiSQL with my personnal host plan, but when I connect to MySQL with my host, I connect with "localhost" in PHP but at work, I connect to databases with something like "supersqlserver.foo.net"... ...
Hi, I'm having a hard time trying to test weather a record in the database exists for a perticular ID in django. something = User.objects.get(id=myID) if something is None: text="No Record" I need to do something like this. ...
Hello ! Can someone explain me why with that query: SELECT * FROM `tags` WHERE (tag IN ('willa-lentza', 2016)) it return me all rows from tags table, but when I put 2016 into quotes it works good ? tag column is varchar type. SAMPLE ENVIRONMENT CREATE TABLE `tags` ( `id` int(10) unsigned NOT NULL auto_increment, `tag` varchar...
Hi, I have a website that offers a service to subscribed members. It has been reported to me that one of the pages that has a form used to submit data to a mysql database has not been displaying saved changes. The form should display back data that has been stored in the database. (After the page has been submitted) I thought this was...
I'm working on an ETL using C# in which extracts data from a remote MySQL database that requires an SSH tunnel to connect. I currently have it working such that I first create my SSH tunnel manually using PuTTY and then programmaticly connect to the database normally using a MySqlConnection object, etc. How can I programmatically creat...
is it necessary to use mysql_close() at the end of a query in PHP? ...
mysql > path_to_bin/name.exe Is there a solution? ...
I'm using mysqli. When I echo mysqli_real_escape_string($db,mysqli_real_escape_string($db,'"')); which one of those will be the output: 1. \" 2. \\\" ? Is there a safe way to check whether a string has been already escaped? Unfortunately, I cannot test at present as I cannot access MySQL for 24 hours. ...
Hello, i have a really complex query (mysql + php) and i would like to know the easiest way to sum columns and rows of a table apart from using SUM(x). Maybe a javascript could help. Thanks in advance. ...
Since there is no function to check whether a string is escaped before entering it to the db, how can I do this with regex? $string = 'some" string'; if(!preg_match('//',$string)) { $string = mysqli_real_escape_string($string); } php manual: mysqli_real_escape_string backslashes characters encoded NUL (ASCII 0), \n, \r, \, ', ...