Error While Deleting row from multiple dependent tables [closed] - mysql

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
ERROR: syntax error at or near "r"
Query was:
Delete r,ur from un_received_compansation_reason ur join received_compensation_info r on received_compensation_info.compensation_info_id = un_received_compansation_reason.compensation_info_id where compensation_info_id=2

You have specific table aliases, so try writing the query as:
Delete r, ur
from un_received_compansation_reason ur join
received_compensation_info r
on r.compensation_info_id = ur.compensation_info_id
where r.compensation_info_id = 2;

You need to use table aliases in time joining key like below
Delete r,ur from un_received_compansation_reason ur join
received_compensation_info r on
r.compensation_info_id = ur.compensation_info_id
where ur.compensation_info_id=2

Related

MySQL : How to I, join this table? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
I have table like this, and i want to output the result like output table, can anyone tell me how to do it, in MySQL
You can use left join like so :
SELECT tb_session.SESSION AS SESSION, tb_class.CLASS AS CLASS from tb_schedul LEFT JOIN tb_session ON tb_schedule.ID_SESSION = tb_session.ID LEFT JOIN tb_schedul.ID_CLASS = tb_class.ID
Good morning, you can use LEFT JOIN
try it:
SELECT tb_session.SESSION, tb_schedul.ID_CLASS FROM tb_session LEFT JOIN tb_schedul
ON tb_session.ID = tb_schedul.ID_SESSION;

Random Number in MySQL column [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to add random number in one of my database column called likes which have about 5000 row in it. currently I have tried like below to get random number from 10 to 50.
$randomnumberlike = (rand(10,50));
but this is setting same number in all row...instead I want different number in row...anyone can please suggest how can I do it ?
Thanks
Try: UPDATE Table SET fieldName = ((rand() * 1000) % 40) + 10;
Because when you preset it in a variable, it'll be the same for all...
You're setting a variable:
$randomnumberlike = (rand(10,50));
If you're then using $randomnumberlike to add to the db then it will always be the same, its already be assigned (unless within a loop), you need to use (rand(10,50)) (or working similar) directly in the query like this:
UPDATE <table_name> SET <field_name> = ROUND((RAND() * (50-10))+10) WHERE ...;

Mysql Error: Table does not exist [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
When I try to login a user account on my Page, I get the following error:
Table 'mysql.users' doesn't exist
I have checked that I have only one 'mysql' table and that is named User not Users.
Someone please guide me how to get rid of this error. Can I change the Table name to "User"?
Right now I have the following code:
query("SELECT * FROM `users` WHERE `username`='" . $mysqli-
real_escape_string($useroremail) . "' and `password`='" . md5($password) . "'
and `userlevel`='".($vendor==true ? 30 : 20)."'LIMIT 1;") or die($mysqli->error);
Can i change the Table name to "User"?
Yes you can.
Try this.
RENAME TABLE `oldTableName` TO `newTableName`
RENAME TABLE 'Users' TO `User`
Hope this helps.

How can I fix the Syntax Error in the subquery? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am trying to find the Age based off date of birth. I keep getting a syntax error in the subquery.
I'm getting on error on the - CUST_DOB /365,0) As Age from customer; to use the correct syntax. Error Code 1064
SELECT CUST_LNAME, CUST_FNAME, ROUND((NOW() – CUST_DOB)/365,0) AS AGE
FROM CUSTOMER;
There is a problem with the minus (-) sign. please use it like
SELECT CUST_LNAME, CUST_FNAME, ROUND((NOW() - CUST_DOB)/365,0) AS AGE
FROM CUSTOMER;

Replace character between numbers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I converted phpbb2 forum to phpbb3.
But I have problem with phpbb2 posts links which remained in MySQL database.
phpbb2 posts links are eg.
/viewtopic.php?p=106352#106352
and phpbb3 are:
/viewtopic.php?p=106352#p106352
(there is letter p after #)
Current links from phpbb2 are not working, after convert,
so I need help replacing # between posts id (numbers) in MySQL DB.
I got a lot of links like:
/viewtopic.php?p=106352#106352
and I need to replace # with p ( add p at the end)
like:
/viewtopic.php?p=106352#p106352
I don't know much MySQL, so I stuck.
Please help
One possible approach:
UPDATE phpbb_posts
SET post_text = REPLACE(post_text, '#', '#p')
WHERE post_text REGEXP '^[^#]*p=[0-9]+#[0-9]+$'
WHERE clause is specified to prevent updating links that do not follow the format.
SQL Fiddle.
select replace('/viewtopic.php?p=106352#106352','#','#p')
update myTable
set myColumn = replace(myColumn, '#', '#p')
where someColumn = someThing