Tag Info

New answers tagged

1

Join positions to itself. In pseudo-sql: select o.position, n.position from positions as o -- old inner join positions as n -- new on o.application_id = n.application_id and o.country = n.country and o.feed_id = n.feed_id and o.created = <max value for this app, country and feed that's less than n.created> There's a ...


0

You cannot execute multiple MySQL statements from PHP with mysqli_query, but you can with mysqli_multi_query!


1

This is a question more for stackoverflow than for here, but it is great that you asked here first because we would tell you that do not need to handle that on PHP code. MySQL has a syntax called INSERT ... ON DUPLICATE KEY UPDATE that does exactly what you want, in only 1 query instead of 3. There is also REPLACE, although it is slightly different (REPLACE ...


1

Doh! @jynus was exactly correct. Here is the fix: $eventid = intval(mysqli_real_escape_string($dbconnect, $_POST['eventid'])); $sql="DELETE FROM Events WHERE EventID='$eventid' LIMIT 1"; if (!mysqli_query($dbconnect,$sql)) { die('Error: ' . mysqli_error($dbconnect)); } echo mysqli_affected_rows() . " Record(s) Dropped";


3

Use mysqli or PDO libraries for PHP, do not use mysql, as it is deprecated Use prepared statements: they are cleaner, less prone to SQL injection and, in some cases, faster to execute Use exceptions to capture errors throughout your code -query fails, query gets killed, database crashes, unable to connect, ... If you feel intimidated by SQL, an ORM can help ...


0

Albert - could you in future please format your code something like this? It makes things much easier for those of us who are trying to help you :-). Use the {} code-formatting widget at the top of the question entry panel. You can also quote text (double-apostrophe ") and put in a link (the chain symbol) and do lists and B Bold &c... CREATE TABLE IF ...


0

You have to join the user table to the rank table twice SELECT u.id,u.Name,r1.rank_name Rank,r2.rank_name Supervisor FROM user u INNER JOIN rank r1 ON u.rank_id = r1.id INNER JOIN rank r2 ON u.supervisor_id = r2.id WHERE u.id = 4; or SELECT u.id,u.Name,r1.rank_name Rank,r2.rank_name Supervisor FROM user u INNER JOIN rank r1 ON u.rank_id = r1.id INNER ...


0

With the help of @mustaccio achieved do as follows: First I added the user db2inst1:      db2inst1 useradd Then, I generated the instance (whatever it means)               /opt/ibm/db2/V10.5/instance/db2icrt db2inst1 Edit the php configuration file (/etc/php.ini) for add the instance:      extension = / usr/lib64/php/modules/ibm_db2.so ...


5

This looks like you might have hit a bug logged against Percona Server 5.5: Concurrent duplicate inserts can violate a unique key constraint in InnoDB tables. There is no fix and no reproducible test case for this bug yet. It has only been observed in a production environment. The pattern described is: INSERT a value into a column with a unique ...


1

$data = array( 'title' => $title, 'name' => $name, 'date' => $date ); $this->db->where('id', $id); $this->db->update('mytable', $data);


-1

I think, it's better to use PIVOT. the below link shows how it works : http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx


0

The simple answer: Yes! The complicated answer: Yes! Why would you think otherwise?


2

According to the official Tokutek documentation, TokuDB is only available for 64-bit Linux.


0

You have 3 tables of which only first table is normalized, 2nd & 3rd are not. Normalization works like this: students_info st_id | f_name | l_name | date_of_birth | address | phone 1 | quinoo | mickel | 1/1/1990 | nowhere1 | 1-800-1234 2 | nunoo | gyan | 2/1/1990 | nowhere2 | 1-555-1234 3 | kwanis | nnipa | 3/1/1990 | ...


2

mysql_query() returns false only when there is something wrong with your query and it fails to execute. Otherwise, the return value is a resource which evaluates to success. That is your code always echoes "Account Exists". Check for the number of rows the SELECT statement fetched to determine whether the user exists or not. Your code is also not secure. It ...


2

You should check number of rows in your result set: if (mysql_num_rows($Select_Account_Query) > 0) { echo "Account Exists"; } else { echo "Account does not exist"; }



Top 50 recent answers are included