Latest Databases Posts

Do you have a question?

SELECT MAX(Salary) FROM Employee
WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee )

I need a simple external table definition for preforming loads from FIXED WIDTH files. I don't remember how to do External tables in oracle. This would be a Fixed width, not CSV. I am creating a generator and I need the external table definition.

@Bhavini_2

for sql:" SELECT FORMAT (getdate(), 'dd-MM-yyyy') " this syntex works!

I have to get an instance of Oracle XE running on my laptop. This is so I can test a plsql package I have been working on at my house. Currently out of the job. I seem to remember when I did this the last time I had to configure the tnsnames.ora and listener.ora files correctly. I would like everything to be as simple as possible. Ex, everything should be named XE or something. I can't even find the listener.ora file actually.

Need a brief walk through over the tnsnames.ora file and the listener.ora files.

I'm using SQL Server and used this function to get the format like dd-mm-yyyy.

select FORMAT(GETDATE(),'dd-MM-yyy')

I hve Solved it by replacing loop with While Do

FUNCTION `Calculater`(intrval int, req date) RETURNS date
    DETERMINISTIC
BEGIN
declare calculated date;
declare added int default  0;

WHILE added <intrval do
set calculated = DATE_SUB(req,interval 1 day);
set req=calculated;
IF weekday(calculated)<5  then
set added= added+1;
End If;
end while;
RETURN calculated;
END
Dani 1,932

Have you tried using EXPLAIN to see if you need any indexes?

Have you noticed whether the dates that work vs those that don’t are the ones where you are incrementing the added field?

VIPER5646 10 Junior Poster in Training

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.

I have a database, where I store Job Openings, Where I store Job Descriptions with formats in RichText Box like: bullet points, ordered lists and bold text etc...
But when I save data in MySQL Database and Retrive it from Database it comes format less.

Can anyone help me regarding this issue?

Thank you for the replies! Will these get back my missing databases i tried both nothing happened

Dani 1,932

Oh never mind. Just discovered this thread is 5 months old. I guess you already found the bug.

Dani 1,932

Also, post your code here so we can try to find the bug.

Dani 1,932

I forgot to mention that LOGO was somewhere there in the elementary school years as well.

Dani 1,932

My first programming language was BASIC on my Apple IIGS when I was five or six years old.

We had just gotten a computer and I was really excited about it. I asked how to use it and my computer-illiterate mom said to read the manual, so I did. The manual said that if I press Ctrl + Open Apple + Reset then I could boot into a BASIC interpreter and came with a manual of some of the basic commands that you could use.

I just had a ball typing things like PRINT 12 + 29 = and having it tell me the same answers I came up with on my math homework. I never cheated of course. I was way too nerdy for that.

Anyways, that progressed to doing things like GOTO statements and simple but yet more elaborate programs in my elementary school years.

When I was 12 or 13, I convinced my mom to buy me Visual Basic 4 and I wrote a typing tutor. It was basically a Mavis Beacon clone as I was verrrrrry big on improving my typing speed at that time. I can now type nearly 200 wpm.

When I was 15 I took a class on C++ and then at 17, taught (with teacher oversight) two C++ classes for the required volunteer credit to get into the National Honor Society.

In college they continued to teach us C++, but since I knew it already, I tutored freshmen and sophomores through a ...

rproffitt commented: Thanks. Always interesting to read origin stories. +0
Dani 1,932

When I was in school, we were required to use Turbo C++. However, it was 1997 at the time.

rproffitt commented: It was 1972 and my first programming as on a GE 210. Assembler, paper tape, core memory, switches. +15
Dani 1,932 The Queen of DaniWeb

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 highest id value and delete the others).

Alternatively, if you do want to add that UNIQUE index, you can do the following to brute force dropping duplicate rows:

ALTER IGNORE TABLE TABLE_NAME
ADD UNIQUE INDEX index_name (duplicate_field);

https://superuser.com/questions/1008349/unable-to-connect-to-localhost-after-windows-10-upgrade notes two things I've done to resolve this.

  1. Ping 127.0.0.1 (strange that fixes it).
  2. Open the hosts file and correct it if need be.
Dani 1,932

So I also use MySQL and not SQL Server, but I know with MySQL I have to specify the character set for individual table columns as well as the character set for my connection.

Andre had the right idea in that you want to be using the UTF-8 character set. I’m just not sure where in the SQL Server software you can configure that.

Dani 1,932

localhost and 127.0.0.1 should point to the same location. 127.0.0.1 is the IP address for localhost, your local machine.

I'm using phpMyAdmin to manage my databases, I have 2 projects that use 2 different database the first one uses 'root'@'localhost' and the 2nd is 'root'@'127.0.0.1' I don't know how i ended up using 2 different server but it was working fine until i tried to edit codes with the 1st project that uses 'root'@'localhost', I was trying to select from a table to be loaded to a DataGridView when an error popped up saying "Host 'hostname' is not allowed to connect to this MySQL server". The 2nd project is working fine. This only happened after I try to create a module for connecting to mysql database since the earlier code for connecting to mysql is written in every form.

I went to the mysql.user table to check if i can edit users and passwords, I tried. But any command that I try to do won't work, after getting back to my databases, when i try to select anything phpMyAdmin says "No database selected". After closing and opening it again every single database is all gone.

I don't know where i f'd up. I'm sorry if this is a dumb question to ask I just really need help. I'm already thinking uninstalling and reinstalling wamp and then recreating all the lost database but im still hoping there is another workaround here.

Try this code :
CREATE TABLE Example (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
name varchar(30) NOT NULL,
age int
);

zzz.png

Just after your mysql_connect()

mohamedrani commented: i'm not using any UI or frontend , i'm working on SQL server itself +0

Hi Mohamedrani

Assuming you are using MYSQL with unicode support, you need to set the charset after connecting to the database:

mysql_query("SET NAMES UTF8");

You may have to tell the browser that you are sending out UTF-8 chars as well?

Hope this helps

mohamedrani commented: thanks for your comment , but a question , where should i put that line? +1

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 except English

I have tried but get an error "Cannot define PRIMARY KEY constraint on nullable column in table Application" in SQL Server 2018

rproffitt commented: Don't hijack old discussions that can't possible apply. 2016 above and you are asking about 2018. Make a new discussion. -3

Thank you for the data.

I think I want to use Redis in the same way you use it too so I am happy I got the right one.

I moved onto using javascript so i write all of my html directly in as javascript code which is loaded in the client-side memory

Dani 1,932

Memcached is simpler, faster, and has less overhead. I use it to cache large portions of pre-generated HTML to reduce the amount of PHP and MySQL that needs to execute to build a page. I use Memcached when there’s absolutely nothing to lose if it ejects a key too early and I just need it to cache long strings of content to save a few milliseconds from page loads.

I use Redis when I need to take advantage of its ability to store volatile data objects in a fast and reliable way, such as to store user session data, API tokens, etc. In such cases, I use Redis as the primary database because MySQL is not performant for us when working with active sessions, and file based sessions (PHP native sessions) are slower over the network when being accessed by multiple web servers than our Redis server is.