Member Avatar

Hi there, Not sure if I am in the right place, but I wanted to ask where I can access a csv file for all the streets in Belgium?

Member Avatar
0
30
Member Avatar

Hi all, I have a question about updating two values in a sql table using a subquery. My database is called books and the below table books too: id title author location_id 11 Tera Netrear 4 14 Disser Bubu 1 15 Tenno Puoio 4 16 Oban Tyrone 5 18 Sisnobi Teru 3 Location_id is indeed another table as it's a foreign key in this table but that shouldn't matter. So what I want to do is to change all the location_id currently at 4 to 2. I know i could do it like this `update books set location_id = 1 …

Member Avatar
0
117
Member Avatar

Hello. I am making a database using SQLite. Then I need to make an API with functions that returns information about that database. Then I need to print out a report. However, when I try to return an answer to a query using inputs, nothing is returned. I either get an empty array or I get "<sqlite3.cursor object="" at="" 0x034d2d20="">". If I put default values in the query and not inputs, values are returned. Does anyone have any idea's on how I can fix this please (see below for more information)? Thank you in advance! Here is the code that …

Member Avatar
0
172
Member Avatar

I'm trying to create a trigger that does two things, first take an ip that's in dot notation and run inet_aton on it and put the result in another field. Second, checks a lookup table to identify an ip range that the result of the first action falls into and enters the id of that row in the table. Do I have to break this down to separate triggers, a before insert and an after insert? This is a mysql database. DELIMITER // CREATE TRIGGER download_ins BEFORE INSERT ON download FOR EACH ROW begin declare vip varbinary(16); select `ADDRESS` from …

Member Avatar
1
161
Member Avatar

Hi all, Before I begin this question, and before you tell me we dont do homework, I would like to state that I have read a few articles, I have tried a couple of functions (=REPLACE, =SUBSTITUTE) but i'm not able to get the reuslts require, I'm new to Excel Question: Useappropriate text functions to shorten the variable names to something like Arizona Females Young, Arizona Females Old, and Arizona Females All, also is there a way to do it automatically for all variables in 1 function. The screenshot is attached. It is kind of urgent (I understand people help …

Member Avatar
0
155
Member Avatar

My code has a query that looks like: INSERT INTO table VALUES (...) ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id), ... id is a PRIMARY KEY. My question is that I can't for anything remember why I have id = LAST_INSERT_ID(id). I wrote it years ago and it's not commented. Can anyone think of a reason why I was doing this?

Member Avatar
0
921
Member Avatar

I've just started working with PHP and MySQL, and I'm trying to create a table in MySQL. If I've got this right, I'm trying to do so by going to my host's SQL MyAdmin page and typing in mysql_query("CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)") in the query tab. I get an error saying that my syntax is wrong. Any advice?

Member Avatar
0
783
Member Avatar

[B]Mysql - How to use UPDATE with SELECT???[/B] I have two tables: [B]1) products_category[/B] -cat_id -cat_name [B]2) related_category[/B] -rel_cat_id (exaclty same as products_category.cat_id==related_category.rel_cat_id) -rel_cat_name [B]products_category table[/B] [IMG]http://www.ephpsolutions.com/scud/rrr/product_category.gif[/IMG] [B]related_category table[/B] [IMG]http://www.ephpsolutions.com/scud/rrr/related_category.gif[/IMG] I want to get cat_name from products_category and want to store in rel_cat_name in related_category tabel. and the query should be only one. Not sure how will it works. I thought it would be something like: [CODE] UPDATE related_category SET related_category.rel_cat_name = ( SELECT product_category.cat_name FROM product_category INNER JOIN related_category ON related_category.rel_cat_id = product_category.cat_id )[/CODE] But it doesn't works, Please assist. Thanks in advance

Member Avatar
0
42,349
Member Avatar

I Have **"user_chat"** table name his 4 columns "msg_id" Auto Increament "chat_from_id" "chat_to_id" "chat_msgs" SELECT `chat_msgs` from `user_chat` where chat_from_id='2'AND chat_to_id='10' LIMIT 0,10 Also I have used **DESC** using above queary but not worked I want to fetch last **5 recent records** from **"chat_msgs" columns** Suggest me. Thank you

Member Avatar
0
378
Member Avatar

Hello all. I have a funtion in MYSQL to substruct days from a date. This function seamsto work but some dates it times out. This is my function CREATE DEFINER=`root`@`localhost` FUNCTION `Calculater`(intrval int, req date) RETURNS date DETERMINISTIC BEGIN declare calculated date; declare added int default 0; Lbl_Loop: Loop IF added=intrval then leave lbl_loop; End IF; set calculated = DATE_SUB(req,interval 1 day); IF weekday(calculated)<5 then set added= added+1; End If; end loop; RETURN calculated; END If I do **select Calculater(1,"2020-02-04")**; it works, but **select Calculater(1,"2020-02-02")**; it runs for a few seconds and My SQL times out. Thanks in advance.

Member Avatar
0
1,085
Member Avatar
Reusable Code Snippet Delete duplicate rows in MySQL

Sometimes you need to delete duplicate rows in a database :) In the future, set UNIQUE keys when you need them :) In the example below, we have a table appropriately named `TABLE_NAME` and there are multiple rows that have the same value for the `duplicate_field` field. In this example, we want to remove the ones where the `id` field is set to "remove". In other examples, you can pick any conditional you want when choosing which of the rows to remove or which to keep, including conditionals between them (e.g. `foo.id < bar.id` will keep the row with the …

3
2,565
Member Avatar

Hello guys, i've the following table in database : IdCity int CityName nvarchar(20) it has the data like this in it : IdCity CityName 1 Абакан 2 Азов 3 Александров 4 Алексин 5 Альметьевск 6 Анапа when i try to run the following view SELECT IdCity, CityName FROM dbo.City WHERE (CityName = 'Абакан') i get the results null, althought that record in the table i tried to add a record with cityname= 'abc' and ran the view with this parameter, it worked fine so it only doesn't get results written in russian any ideas? SQL query problem with any language …

Member Avatar
0
894
Member Avatar

I come across this problem every so often and end up having to do work arounds when I would prefer to keep it in the database. I have a query where the data in the query updates frequently so the query won't stay in the cache but I don't need the query to be accurate. I was trying to avoid adding an extra step of storing the data in a temp table and having to update it on a timer. Does anyone know of a way to get MariaDB or MySQL to Keep the result set for a period of …

Member Avatar
1
1,106
Member Avatar

Hi all, I wanted to procedure to return number of days and weekdays between two dates. This is what I came up with and it seems to work ok, but I'd like to read what others think. And if there's already a single line function for this, oops. Also, I'm not too comfortable with when to use @variable or just variable. Thanks. DELIMITER $$ CREATE PROCEDURE `DATEDIFF_WEEKDAYS`(IN `IN_from_date` DATE, IN `IN_to_date` DATE) BEGIN DECLARE TOTAL_WEEKDAYS INT DEFAULT 0; DECLARE TOTAL_DAYS INT DEFAULT 0; DECLARE FROM_DTE DATE DEFAULT NOW(); DECLARE TO_DTE DATE DEFAULT NOW(); DECLARE CURR_DTE DATE DEFAULT NOW(); IF(IN_from_date = …

Member Avatar
0
3,361
Member Avatar

I am using bootstrap modals, when i query to populate a dropdown to fill in to my form, my query is show all but the first record and i can't figure out why. My form looks like this <div class="form-group"> <label for="deptcode">Department</label> <select class="form-control" id="deptcode" name="deptcode" value="<?php echo $mem['deptcode'];?>" <?php $departments = $mysqli->query("Select * FROM department ORDER BY deptcode"); while ($dept = mysqli_fetch_assoc($departments)){ $tempdeptname = $dept['deptname']; $tempdeptcode = $dept['deptcode']; //see what the current name is and display it first if ($tempdeptcode == $mem['deptcode']) echo "<option value='$tempdeptcode' selected='selected'>$tempdeptcode ($tempdeptname) </option>\n"; else //if blank display first item in dropdown list echo "<option …

Member Avatar
0
887
Member Avatar

All Time Show Null value Please help me what is the wrong in my code declare @mxdbvlu int declare @dbvlunm int set @mxdbvlu= (select max(Database_name) from TBL_FY_SELECT_1) if @mxdbvlu = null set @dbvlunm=1000 else set @dbvlunm=sum(@mxdbvlu+1) select @dbvlunm,@mxdbvlu

Member Avatar
0
3,918
Member Avatar

DaniWeb was written in Codeigniter, and when posting to the forums, we use database transactions that look like this: $this->db->trans_start(); ... insert into the posts table ... ... update the member's post count ... ... update the tags table ... etc $this->db->trans_complete(); On occassion, the error log will show for a particular query within the transaction: *Query error: Deadlock found when trying to get lock; try restarting transaction - Invalid query* When that happens, the entire transaction is rolled back. However, this is not ideal because when someone attempts to make a post, we don't want it to completely fail …

Member Avatar
1
2,273
Member Avatar

Here is a basic question, what is the fastest way to transfer a MySQL database? Here are the variables at play: 1) Database is just shy of 3GB 2) Transfer is between two servers running different versions of MySQL 3) There will not be usage of the database during transfer, I can even shut down MySQL if needs be. 4) The database is mostly MYISAM but with a few InnoDBs and a couple Memory (VBulletin) 5) Both servers are Linux based and I have root access on both. I've done the transfer using a mysql dump, but the import took …

Member Avatar
0
3,083

The End.