inverse of a numeric column in mysql

I have a mysql database column with numbers like 5,10,-2,-8,0. i need to convert all negative numbers to positive and positive numbers into negative. For example, if I have a positive number like 1 , 5 , 6 then i need to get -1 , -5 , -6 also -4 , -8

Laravel optional where () query

I wonder if there is something like a optional where query. Eg: Select * from table where X must be = 2 and Y must be equal to 0 or 1?You may try as: $userId = $request->input('userId'); ->where('X', 2) ->where(function($q) use($userId) { $q->

Remove wp tags from a table correctly

I need to remove some tags periodically from my wp table. Right now I'm using this: DELETE FROM wp_terms WHERE slug = 'tag-to-delete'; But I suppose that the way I'm doing this is not correct because I think I must delete also all the relations with

Mysql check The constraint does not work

I'm going to use mysql constraints to prevent inserting numbers less than zero. I found this query from W3schools. CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(25

Records between NOW () and 3h today or yesterday

How can I get records in a table between NOW() and the previous 3am? This would be easy if it's 9am, but how do I write this if it's 2am? i.e I want the trades between DATE_SUB(CURDATE(), INTERVAL 21 HOURS) and NOW(). I'm looking for some code which

Why do I have a MySQL syntax error when doing subqueries?

Below is my query that need to make views from the sub queries and then run the math at the top. I get a syntax error when I run it. I have done subqueries before so I may just be tired and do not see the issue. SELECT STDDEV(north.value)AS north, ST

How to get the username and password phpmyadmin

I have intalled phpmyadmin recently in my system. Now I lost its username and password. I tried the below methods for login. in etc/phpmyadmin/config.inc.php I activated the AllowNoPassword $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; Step 1: Locat

Get emails from MySQL and send them emails

I'm trying to get the emails which have "all" under "selectedoption" column from MySQL database table and then sending emails to them. Here is my PHP code: <?php include("config.php"); $con = mysql_connect($opt_host, $opt_

Java order of class fields and singleton methods

I have a surprising problem that any amount of Googling is not helping. I was hoping I can clarify here. I declared a Java singleton for connection pooling my JDBC/MySQL DB using eager initialization like so: public class SomeConnectionPool { private

mysql rank - line number where field is equal to X

This is my mysql DB: id, auth, name, points and what I want to get is to create a rank. So sort all the records by points, and get the number of the row where the auth field is equal to '1' I were looking for this in stockoverflow archive, in google

MySQL query error - newunk column

My query string is $chk_cookie="SELECT * FROM cookie_data_mst WHERE uniqid_client=5279f0addc835 AND cookie_data=3"; $chk_query=mysql_query($chk_cookie) or die(mysql_error()); this give the error unknown column. if I put ' in value '5279f0addc835

Best way to store text for MySQL tables

I'm developing a board that allows people to list and search for Minecraft servers (that people have submitted). I'd like to give people the ability to submit a short, 300 word description about their server when submitting it, however, I'm unsure wh

Selection of non-matching fields in mySQL

I have three tables as follows: Contact, Custom_Field, Custom_Field_Value. Each contact can have one Custom_Field_Value record for each Custom_Field. So there is a 1:many relationship between Contact and Custom_Field_Value but it isn't quite that sim

Get UNIX TIMESTAMP in the django API call

I have the following query: users = Analytics.objects.values('date', 'users').order_by('date') [(datetime.date(2012, 8, 20), 156L), (datetime.date(2012, 8, 21), 153L),...] How would I get the unix timestamp of the datetime here? The equivalent of doi

MySQL master-slave-slave configuration

Quick questions about MySQL Master-Slave-Slave set-ups: I currently have a Master-Slave set up right now and I would like to add another slave. Would it be possible to clone the server running the slave, and then spin up a new server with the image f

Download an image from Android to the MySQL database

Good day! I am trying to search for a basic tutorial of uploading an image file from Android to an online MySQL database, but I can't find any. I am now making an activity that can upload a user's profile picture from the Android to the online server

PL / MySQL is there?

In Oracle there is PL/SQL, a powerful imperative language. Is there anything similar for MySQL?While MySQL does have similar components, no, you cannot use PL\SQL in MySQL. The same goes for T-SQL used by MS SQL Server. MySQL has plenty of documentat

rename the download file, add a new name to the database

I'm using the following code to upload and rename files. That part works awesome, however it also posts some data to a db table. The problem is the old name is getting posted to the db, but the file is renaming to the ID...how can I get the new name

MySQL query looking for 24 hours of data only

I am trying to retrieve only the data for a 24 hr period. The sql I have is: SELECT * FROM aprstrack WHERE callsignSSID = 'VE9SC-9' AND reporttime BETWEEN SYSDATE() - INTERVAL 1 DAY AND SYSDATE()) ORDER BY reporttime ASC can someone tell me where I a

sql query condition

l've a table named gst that contain CREATE TABLE gst ( gst_id INT PRIMARY KEY AUTO_INCREMENT, month VARCHAR(9) NOT NULL, price INT NOT NULL ); INSERT INTO gst (gst_id, month, price) VALUES ( 7, February, 3), ( 16, January, 5) ( 17, April, 7), ( 18, M

Unable to put Joomla articles open to a good URL

Problem: My articles have the right urls: for example, newsite.com/article. However, by clicking an article I get an empty article. I can see my sidebar. I moved my Joomla installation to a different folder in my server. I want to change my domain fr