bubblegum.anarchy
Members-
Posts
526 -
Joined
-
Last visited
Never
Everything posted by bubblegum.anarchy
-
UNLOCK TABLES ?
-
This is a fun query to create: SELECT ProductID , group_concat(DISTINCT subjects.Name SEPARATOR '\n') AS subject_names , group_concat(DISTINCT grades.Name SEPARATOR '\n') AS grade_names , products.Name FROM products INNER JOIN subjects ON find_in_set(subjects.SubjectID, products.SubjectID) INNER JOIN grades ON find_in_set(grades.GradeID, products.GradeID) WHERE ProductID = 84512 GROUP BY ProductID
-
Poorly Written Query or Crappy Performance?
bubblegum.anarchy replied to zeep25's topic in MySQL Help
I do not see customerId in customer and no UserEmail in user (I am assuming the information below is not accurate). Linking customer to user with an integer would be more appropriate. -
mysql full text search with html entities?
bubblegum.anarchy replied to joeshacks's topic in MySQL Help
Save some space and time with a query that converts all existing entities to their equivalent characters. -
Consider reading up on session handling from the PHP manual, the following is a basic session handling extract: Example 1860. Registering a variable with $_SESSION. <?php session_start(); // Use $HTTP_SESSION_VARS with PHP 4.0.6 or less if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { $_SESSION['count']++; } ?> Example 1861. Unregistering a variable with $_SESSION and register_globals disabled. <?php session_start(); // Use $HTTP_SESSION_VARS with PHP 4.0.6 or less unset($_SESSION['count']); ?>
-
This might look similar to a recent thread where I requested a query to translate `Second Monday March`... I expect `Second Monday March` to return null but I do not expect the same result for the 1st Jan and 26th Jan... anyways.. I have totally flagged the str_to_date function... now the values are being converted in php first since there are not many public holiday dates and I can apply the array in static form to a query using IN ().
-
I really don't think so.
-
using ALTER [iGNORE] TABLE tbl_name ADD INDEX [index_name] [index_type] (index_col_name,...) in something like: ALTER TABLE tbl_name ADD INDEX (id);
-
The InnoDB storage engine is required to implement foreign keys to providing the cascading effect... but the explicit definition of a foreign key is not required if you simply want to link two tables via a reference id, just be sure to index the referencing id and you can use the default low memory myISAM storage engine.
-
Not one query but maybe some better ideas can be gleamed from the following: <?php $request_id = 5 $chunk_count = 5 $result = mysql_query(" SELECT IF(".$chunk_count." - count(*) < 0, 0, ".$chunk_count." - count(*)) FROM tablename WHERE id >= ".$request_id." ORDER BY id"); list($limit_count) = mysql_fetch_row($result); $result = mysql_query(" ( SELECT * FROM tablename WHERE id >= ".$request_id." ORDER BY id LIMIT ".$chunk_count." ) UNION ( SELECT * FROM tablename ORDER BY id LIMIT ".$limit_count." ) "); ?>
-
There is a data typed named bool or boolean that is an alias for tinyint(1) where 0 is false and non zero is true but nothing fixed to just true or false.
-
I supposed you could pass the values with the $_SESSION variable... I do in certain circumstances.
-
LOL - my bad sorry.. remove the extra quote " SQL = "SELECT * FROM smithssc WHERE Zip = "'" & txtZipbox.Text & "'" to SQL = "SELECT * FROM smithssc WHERE Zip = '" & txtZipbox.Text & "'"
-
I can't remember the concat symbol for VB - replace the & with what ever symbol VB uses SQL = "SELECT * FROM smithssc WHERE Zip = "'" & txtZipbox.Text & "'"
-
The more I read the less I understood!
-
[SOLVED] "guessing" next auto_increment number
bubblegum.anarchy replied to itazev's topic in MySQL Help
use mysql_insert_id() to get the last insert id <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('mydb'); mysql_query("INSERT INTO mytable (product) values ('kossu')"); printf("Last inserted record has id %d\n", mysql_insert_id()); ?> -
header("Location: cm_displaysubscriber.php?firstname='.$cm_firstname.'&status='.$cm_status.'");
-
CanMike: The following is straight out of the mysql documention with added underline. Note: The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications. For that purpose, use MD5() or SHA1() instead. Also see RFC 2195 for more information about handling passwords and authentication securely in your applications.
-
mysql stores dates as YYYY-MM-DD
-
string mysql_field_name ( resource result, int field_offset ) <?php /* The users table consists of three fields: * user_id * username * password. */ $link = @mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect to MySQL server: ' . mysql_error()); } $dbname = 'mydb'; $db_selected = mysql_select_db($dbname, $link); if (!$db_selected) { die("Could not set $dbname: " . mysql_error()); } $res = mysql_query('select * from users', $link); echo mysql_field_name($res, 0) . "\n"; echo mysql_field_name($res, 2); ?> The above example will output: user_id password and use int mysql_num_fields ( resource result ) for a field count
-
There is an extra leading ' in the query error message. I tried the following query successfully: SELECT CONVERT(_utf8 '%#eFrag.css|ÄλÑÒœ%' USING latin1) COLLATE latin1_swedish_ci;
-
Can a trigger insert records from one database table to another?
-
Use hidden fields <input type=hidden> or have the script create the static html page 3.
-
The str_to_date function is driving me nuts.. working one minute and not working the next (returns null when not supposed to). I have a simple public_holiday table with an `occurs` field of type varchar(255) not null default '1st January'; I have tried all manner of string data types and even setting the field to allow null but the function remains sporatic the query used is: SELECT str_to_date(occurs, '%D %M') FROM public_holiday; #works one day and returns null the next SELECT str_to_date('1st January', '%D %M') from public_holiday; #always works table contains: 1st January 26th January Second Monday March Before I give up on the function completely, does anyone know what might be causing the null returns?