SQL INTEGER & VARCHAR not showing - mysql

MY SQL is not showing the INTEGER, VARCHAR,DECIMAL, DATE Option [No opting in the drop-down: i'm using popSQL ] I tried with the sample table on the popSQL website
I was Trying to create STudent ID column but no option ti specify INT or VARCHAAR:
Can you help me with this? Thanks
I tried to look up on YT but no one spoke anything about this specific issue

Related

How to select database with dot in its name with laravel?

i have a project to show database value...
but, the database name has dot in it.
my database name is "t.produk".
How can i select the database in laravel?
i run it and got an error says it invalid like below
EDIT:
and i also did it with just string, came out error too :
Here the picture
First of all - avoid naming database tables like that. You should not use any dots there. It could be t_produk as example.
But table name should be descriptive so go for something like products. Than name your entity as Product.
You get this error here because you can't set variable as (t.produk). You should pass a string as I see here. So do it like this:
protected $table = 't.produk';
EDIT:
I saw the error with a string variable. So now you see why the current table naming you choose is quite not good. DB reads it as follows:
select from database t table produk
If you will name your table like t_produk problem should be no longer here.
My bad, so the tables name can't have dot in it. noted.
Btw y'all thanks for the answers :)

" ( " not valid in this position, expecting an identifier in MySQL

Today is, 1/30/2022, I have been following along with an #AlexTheAnalyst video. I am on a Mac and using MySQL version 8.0.27. (The video is using windows based SQL Server Workbench) I am stuck! I am trying to creating a temporary table function. MySQL is not liking the # in the table name #PercentPopVaccinated as used in the video. When I remove it and run the function/query without the # I get 0 rows returned. I have researched on stackoverflow etc. and I am not coming up with a solution that I understand. (Newbie here)
I have dropped the table that was created and I am starting over.
I am getting an error when creating the temp table that states MySQL is expecting an identifier after the first " ( ". Anyone else have a similar issue?
Create Table #PercentPopulationVaccinated
(
continent nvarchar(255),
location nvarchar(255),
date datetime,
population numeric,
new_vaccinations numeric,
RollingVacCount numeric
)
Insert into #PercentPopulationVaccinated
Select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations
, SUM(cast(vac.new_vaccinations as UNSIGNED)) OVER (Partition by dea.location Order by dea.location, dea.date)
as RollingVacCount
-- (RollingVacCount/population)*100
From project_portfolio.covid_deaths dea
Join project_portfolio.covid_vaccinations vac
On dea.location = vac.location
and dea.date = vac.date
where dea.continent is not null
-- order by 2,3
Select *, (RollingVacCount/Population)*100
From #PercentPopulationVaccinated;
So I'd say the underlying problem is that you are watching a video tutorial that is using SQL Server, but you are using MySQL. There are many similarities, but it is not going to be an exact match. For instance, the # sign creates a temporary table in Sql Server, but the # is not valid in MySQL. If you want to use a different database service than the tutorial you are watching is for, you are going to have to translate some concepts for yourself.
Another commenter already posted this link, which indicates the syntax for creating temp tables in MySQL.
https://dev.mysql.com/doc/refman/8.0/en/create-table.html#create-table-temporary-tables

CAST() function MYSQL doesn't seem to work for me? need help please

Hi everyone so the issue I am having is that I am trying to use the CAST() function to change a column where the values are stored as varchars into signed(64 bit integers) so that I can sort the table by the value of the integers in that column. Below I am sharing the code I am using in MYSQL and an image of the table so you can see what it is I am working with. The problem is when I try to sort by emp_id after running the code it still won't sort properly based on the integer value and I am not sure what I am doing wrong. Any help is greatly appreciated.
SHOW databases;
USE ex;
SHOW tables;
SELECT *
FROM string_sample;
SELECT CAST(emp_id AS SIGNED), emp_name,
FROM string_sample;
Problem solved seems to be what was causing the issue was that after my use of CAST(emp_id AS SIGNED) I didn't give it an alias when I changed the line to CAST(emp_id AS SIGNED) AS emp_id the table behaved correctly and converted emp_id to an int which allowed me to sort it by the emp_id values correctly.

Talend - Check columns lenght before inserting into mysql database

I'm trying to use Talend Open Studio for Data Integration for a BI school project. I have a txt file with some data like this :
NoClient;Name;Region;State;City;Postcode
24;Edna Thomas;West;California;Laguna Niguel;92677
I used jobs to transform data and insert it into tables. It works nicely.
Now, I'd like to handle SQL errors. For example, if the column length specified in the DB is 10 and if the job tries to insert a 11 length data in that column, I will get an SQL error.
How can I achieve it ? Is there a specific feature in tMysqlOutput or should I simply use triggers like this to check data before inserting :
CREATE TRIGGER my_trigger
BEFORE INSERT
ON my_table
FOR EACH ROW BEGIN
IF (SELECT LENGTH(NEW.Noclient)>255) THEN
// instructions
END IF
Hope it's clear enough ! Thanks in advance, sorry for bad english :-)
Maybe you can do a check in each variable in a tmap.
Like for example :
StringHandling.LEN(var) <= 10 ? var : StringHandling.LEFT(var,10)
And you adapt in function of the size of your field.
There's a component for this: tSchemaComplianceCheck
A nice example can be found at:
http://dwetl.com/2015/03/30/data-validation-using-tschemacompliancecheck/

Mysql "Time" type gives an "ArgumentError: argument out of range" in Rails if over 24 hours

I'm writing a rails application on top of a legacy mysql db which also feeds a PHP production tool. Because of this setup so its not possible for me to change the databases structure.
The problem I'm having is that two table have a "time" attribute (duration) as long as the time is under 24:00:00 rails handles this, but as soon as rails comes across something like 39:00:34 I get this "ArgumentError: argument out of range".
I've looked into this problem and seen how rails handle the time type, and from my understanding it treats it like a datetime, so a value of 39:00:34 would throw this error.
I need some way of mapping / or changing the type cast so I don't get this error. Reading the value as a string would also be fine.
Any ideas would be most appreciated.
Cheers
I'm not familiar with Rails so there can be a clean, native solution to this, but if all else fails, one workaround might be writing into a VARCHAR field, then running a 2nd query to copy it over into a TIME field within mySQL:
INSERT INTO tablename (name, stringfield)
VALUES ("My Record", "999:02:02");
UPDATE tablename SET datefield = CAST(stringfield as TIME)
WHERE id = LAST_INSERT_ID();