Search the Community
Showing results for tags 'sql'.
-
Curious. When querying SQL data in PHP, if I want to output data from a table result with a fetch_assoc, I'd have to always use column names. If I know the column position, is there not an option to just get the row for the position of the column rather than the name of it? If an SQL table exists like this: ID, DOB, first_name, last_name and I want Date of birth and I know it'll always be the 2nd column, a pseudocode like it would be something like: $row[1]; instead of how you'd always have to reference it: $row["DOB"]; Sort of getting annoyed with how rigid PHP is when it comes to SQL. If I could just use positions I could make my code far more flexible instead of hardcoding each column on its own. On second thought, I feel like this is a non issue and I'm just looking at a roundabout way of overcomplicating my code. Am I going insane?
-
Hello, For some time now, I've been trying to fix SQL error, related to Database service engine, which always fails to install SQL setup related to it. To explain my story: I've been trying to locate error after error, trying to pin down the culprit of the whole problem I've been facing with, starting from Network-related or instance-specific error 60 up to this. I have looked everywhere, YouTube, various websites and asked some user's help whoever might had a clue on how to fix it. Not until I found an very interesting theory why do I have this problem, of course, it's from Microsoft (weirdly I haven't seen this solution anywhere) Never had a clue about it until now. So I'm asking, wanting to know, are those sector numbers in screenshot normal? Those numbers are from my local disk I just checked. One of them is set to 16384 (16KB exactly). while the others between are 4096, I also asked my friend's screenshot of him showing how does his local disk's sectors looks like, all the numbers except the LogicalBytesPerSector were 4096, while LogicalBytesPerSector is 512. We both have NVME SSDs as local disks, mine is from Samsung while his is from Gigabyte If anyone wants to know my SSD, it's Samsung 980 500GB m.2 (MZ-V8V500BW) If anyone knows if it's normal, I'm very grateful then, thank you. Edit 1: the operating system is Windows 11
-
So, I am trying to do a "dynamic" loading part of my website (hosting business related) where it displays total clients, total tickets resolved etc. The data is to be fetched from SQL where it displays the highest number. Each SQL table has a ID to it (separate from client ID) and it is that field I want to load. The field is called "id" and I want the code to load the highest number. So if there are an ID number "10", that number will be displayed, and if a new client registers, the new ID will become "11" and then that number should be displayed. How can I make this work as efficient as possible?
-
Hey guys, this is my first post here, hopefully this is in the right section. I have a strange problem with my Ubuntu server. My server is running regularly out of disk space due to the installed MySQL 8 server doing a full backup daily without deleting the old backups. I have configured this backup years ago (some time in 2017, the logs started back than) but I really don't know where the backup script is located and how the backup is configured in general. The only thing I know about this backup is that the SQL dumps are stored in /etc/backups/mysql and that the backup runs daily at 3 AM in the morning. There is also a log file which is written with every backup at /etc/backups/mysql/mysql-backup.log, but the log file does not contain where it is created from. Typical log entry (/etc/backups/mysql/mysql-backup.log): === Start of Backup 20220117_030001 === # Backing up entire DBMS mysqldump: [Warning] Using a password on the command line interface can be insecure. mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces # Retrieving databases mysql: [Warning] Using a password on the command line interface can be insecure. ### Backing up database **TABLE** mysqldump: [Warning] Using a password on the command line interface can be insecure. mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces ... --> Entry repeats for each DB table === End Backup === What I have checked so far: Crontab configurations of all users on the system --> No scheduled scripts found for MySQL backups Home directories of all users on the system -> Could not find any MySQL backup scripts automysqlbackup (typically recommended for MySQL backups) is NOT installed Configuration of MySQL --> I am not aware of any automatic backup mechanism baked right into MySQL Configuration of PhpMyAdmin --> I am also not aware of any automatic backup mechanism in PhpMyAdmin Searched the whole file system for files called *sql*.sh --> This took ages, but I could not find any suitable backup scripts either so the file is probably called something different Back in 2017 I was very unexperienced with Linux servers, this was also one of my first dedicated servers. So I have probably followed some guide on the internet, however this guide might have looked like... I have not used the DB in years so the problem did not raise to my attention until my server run out of space the first time a few months back. Now that I am using the DB regularly, the issue occurs more often and I need to clean up the backups regularly. An easy fix would be to simply delete the backups automatically after they have been created but this does not fix the root cause. Do you have any further ideas how I could find the script on my server which is creating those backups? Thanks for any help!
-
Hi all, I have just started working with Stored Procedures and I have been given this task blow. Would anyone be able to help me under stand all the areas highlighted below. Thank you in advance! ------------------------------------------------------------------------------------------------------------------------------------------------------------ Review the stored procedure “spProfileInformation__c” below. Provide feedback in the following areas: Syntax Errors Common Error Potential performance improvement Any general bugs The Stored Procedure: USE [APTIFY] GO /****** Object: StoredProcedure [dbo].[ spProfileInformation__C] Script Date: 21/04/2021 15:48:49 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[ spProfileInformation__C]( @PersonID int) as BEGIN SELECT p.FirstName, p.MiddleName , x.LastName, p.Prefix, Replace(p.Suffix,' ','') as Suffix, w.UserID, p.PracticingStatusID_Name, p.LawDirectoryOfficPhone__c, p.IncludeLawDirectoryOfficePhone__c, p.LawDirectoryMobile__c, p.IncludeLawDirectoryMobile__c, c.MainEmail FirmEmailAddress, dbo.fnGetFirmAddressLinebyCompany__c(H.id,'line1') FirmAddress1, dbo.fnGetFirmAddressLinebyCompany__c(H.id,'line2') FirmAddress2, dbo.fnGetFirmAddressLinebyCompany__c(H.id,'line3') FirmAddress3, dbo.fnGetFirmAddressLinebyCompany__c(H.id,'line4') FirmAddress4, dbo.fnGetFirmAddressLinebyCompany__c(H.id,'line5') FirmAddress5, dbo.fnGetFirmAddressLinebyCompany__c(c.id,'postcode') FirmPostCode, dbo.fnGetFirmAddressLinebyCompany__c(c.id,'dx') FirmDX, dbo.fnGetFirmAddressLinebyCompany__c(c.id,'county') FirmCounty, dbo.fnGetFirmAddressLinebyCompany__c(c.id,'country') FirmCountry, dbo.fnGetFirmAddressLinebyCompany__c(c.id,'countrycode') FirmCountryCode, dbo.fnGetFirmAddressLinebyCompany__c(c.id,'countrySort') FirmCountrySort, p.PracticingStatus__c, p.PracticingSubStatus__c, from vwPersons p INNER JOIN WebUser w on w.LinkID=p.id INNER JOIN MemberType m on m.id=p.MemberTypeID LEFT OUTER JOIN vwCompanies c on c.id=p.CompanyID WHERE P.ID=@ID END
-
I have these three tables in PHPMyAdmin MySQL. I am trying to make a website where I can add a product to a cart. Products - [Id, Name, Description, Price] Carts/Lists [Id, TotalPrice] ProductsInCarts [CartId, ProductId, Quantity, Price, TotalPrice] But I have no idea how to relate them or how many characters they should allow, neither do I know what type or attribute should be added. I was thinking that products are added to basket in ProductsInCarts where CartId relates to Id in Cart Table, ProductId to Id in Products etc. But I am not sure how to do it.
- 6 replies
-
- mysql
- phpmyadmin
- (and 4 more)
-
Hi! I want to create or look into creating a website for Files sharing, with user accounts that can logg in and see their specific files and nothing else. I have some experience with HTML/CSS as i have made a few basic websites before, nothing spectacular think early 2000's Basically i wanna see what it takes and if i'm able to do it I put SQL and php in the tilte as i assume that's what i need to make something like that. If someone could please point me in the right direction i would appreciate it!
-
Hi all, Currently we use the fingerprint (database_guid) to validate the sql server a client is connected too. I am wondering is there a way set the group id for a few servers so when it's switched, we can check the group_database_id? I ran this comment in SQL to view the database ID's. SELECT d.name, drs.database_guid, d.group_database_id FROM sys.databases d JOIN sys.database_recovery_status drs ON d.database_id = drs.database_id I hope I made sense above and hopefully someone might be able to shine some light on this. Thanks in advance. Scott
-
-
Hello, I have a Class CLASS1 containing multiple Strings, a String array and an Array of CLASS2 CLASS2 contains a String and an Integer, I currently store CLASS1 objects by Serializing them into XML and Deserializing them when I need to read them, but I want to be able to filter them more easily using SQL how can I store them in a way that I can read and filter them using one SELECT command, like I would when deserializing the xml document. The size of the Arrays isn't fixed I tried storing the two arrays in their own tables conecting them using foreign keys to the table were the rest of Class1 values are stored, but when I read them I get an extra output for every Element in each of the arrays, but I want just one output containing every element of both arrays and the other values from Class1
-
So I am currently writing an Asp.net website to track your inventory for an RPG, so I need to read the values for the items, now im wondering what would be the better format to store the items in. I have an class Item consistiong of multiple strings, ints and string[]s this file/table would not be written to by the user the program just needs to filter it to find the right item.
-
package com.example.test1; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.CalendarView; import android.widget.EditText; public class MainActivity extends AppCompatActivity { private mySQLiteDBHandler dbHandler; private EditText editText; private CalendarView calendarView; private String selectedDate; private SQLiteDatabase sqLiteDatabase; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText = findViewById(R.id.editText); calendarView = findViewById(R.id.calendarView); calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() { @Override public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) { selectedDate = Integer.toString(year) + Integer.toString(month) + Integer.toString(dayOfMonth); ReadDatabase(view); } }); try { dbHandler = new mySQLiteDBHandler(this, "CalendarDatabase", null, 1); sqLiteDatabase = dbHandler.getWritableDatabase(); sqLiteDatabase.execSQL("CREATE TABLE EventCalendar(Date TEXT, Event TEXT)"); } catch (Exception e){ e.printStackTrace(); } } public void InsertDatabase (View view){ ContentValues contentValues = new ContentValues(); contentValues.put("Date",selectedDate); contentValues.put("Event",editText.getText().toString()); sqLiteDatabase.insert("EventCalendar",null,contentValues); } public void ReadDatabase(View view){ String query = "Select Event from EventCalendar where Date =" +selectedDate; try { Cursor cursor = sqLiteDatabase.rawQuery(query,null); cursor.moveToFirst(); editText.setText(cursor.getString(0)); } catch (Exception e){ e.printStackTrace(); editText.setText(""); } } } package com.example.test1; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import androidx.annotation.Nullable; public class mySQLiteDBHandler extends SQLiteOpenHelper { public mySQLiteDBHandler(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version); } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } } im making a simple calendar with event but i realize that after type something on certain day i couldn't erase it nor change it. it will stay whatever it was saved as the first time. And also im planning to make the save button open a new activity to insert detail and save into a note in another activity. How do i do that?
-
- android studio
- java
-
(and 1 more)
Tagged with:
-
Hello, I have three tables Table1 with Multiple Columns and one primary key Table2 with one column and the primary key from Table1 as foreign key Table3 with two columns and the primary key from Table1 as foreign key Is it possible to SELECT them in a way that the output is the primary key ONCE in one row with all the matching data from Table2 and Table3 Because if I do SELECT Table1.*,Table2.*, Table3.* FROM Table1 INNER JOIN Table2 ON Table3 = Table2.FOREIGN_KEY INNER JOIN Table3 ON Table1.PRIMARY_KEY = Table3.FOREIGN_KEY I get as many rows as output as there is Matching data in Table2 and Table3 I just want one row per Primary Key
- 13 replies
-
- sql
- sql express
-
(and 1 more)
Tagged with:
-
I had downloaded libgen's desktop and have the data from it, but one of the backup files was a compressed SQL file, and I want to access the files in there, but don't know where to start with SQL...
-
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\techponya\index.php on line x <?php $sql2 = "SELECT * FROM artikel WHERE kategori='technews' DESC() LIMIT 5"; $hasil2 = mysql_query($sql2,$dbconn); while ($techponya = mysql_fetch_array($hasil2)){ ?>
-
so i have a value in a label of one form and i want to get this value to another form and assign it to a variable for doing some calculation.is there a way to get this done?
- 6 replies
-
- sql
- visual studio
-
(and 2 more)
Tagged with:
-
programming How to make a countdown in C# using database values?
Shammikit posted a topic in Programming
i want to make a countdown in c# by taking the ending date from sql server database. so the applications should countdown from the current date to the date in the the database.how can i do this.any suggestions would be very helpful and please dont reply with very advanced ways as im a newbie to C# and sql server.- 3 replies
-
- sql
- sql server
-
(and 2 more)
Tagged with:
-
i have a table called employees that stores the ID,name,salaryamount and the date the record was inserted. the date is recorded in the db using the date datatype.i want to select the most recently inserted record ID from this employee table and store the value of this ID in a variable for doing some calculations.how can i do this using c#? if you dont know a lot about c# but u know the sql query to do this please comment it below.it would be very helpful.thanks
- 9 replies
-
- programming
- visual studio
-
(and 2 more)
Tagged with:
-
I've been trying to get an SQL trigger to work. It is supposed to throw an exception if a tanning bed fee is lower or higher than the requested range by the tanning bed. Upon inserting or modifying the fee in the RESERVATIONS table, I get an error saying that RESERVATIONS is mutating, trigger/function may not see it at line 6. Here's my code: create or replace trigger TriggerCost BEFORE UPDATE OR INSERT on RESERVATIONS for each row DECLARE var_MinimumFee NUMBER; var_MaximumFee NUMBER; var_Fee NUMBER; BEGIN SELECT MINFEE, MAXFEE, FEE INTO var_MinimumFee, var_MaximumFee, var_Fee FROM MODELS INNER JOIN RESERVATIONS ON MODELS.MINFEE = RESERVATIONS.FEE AND MODELS.MAXFEE = RESERVATIONS.FEE; IF :new.FEE NOT BETWEEN var_MinimumFee AND var_MaximumFee THEN RAISE_APPLICATION_ERROR(-20000, 'Input fee is outside of the allowed range.'); END IF; END TriggerCost; What could be causing the mutation?
-
So i want to display some data from a column of a table from the database in a label. i have found a way to display the text in the label from the DB but if the text is too long, only some part of it is displayed.is there a specific number of characters that a label can display?is there a way for me to display all my text from the column of my DB?
-
so i have a read only textbox that displays text from a column in the database.if there is a lot of text to be shown i have to manually scroll down it to see the remaining part.is it possible to automatically expand the textbox according to the amount of content to be displayed? Any help would be greatly appreciated.
- 3 replies
-
- database
- visual studio
-
(and 3 more)
Tagged with:
-
So using the code that i have tried so far i can get the time in 24 hour format.i want to get only the hour from this time and assign it to a int variable.how can i do this? note: i have used the datatype time in this column of my sql server database cn.Open(); string sql = "select time from table1 where ID ='2'"; SqlCommand query = new SqlCommand(sql, cn); SqlDataReader reader = query.ExecuteReader(); reader.Read(); String dbt = reader["End_time"].ToString(); reader.Close(); cn.Close(); int f = int.Parse(dbt);
-
Having issues with creating Foreign Keys. How would I end up doing the linking of the FK with PHPMyAdmin? I get errors when I do it using constraints. Thanks for the Help! Create database cardealerships; use cardealerships; CREATE TABLE tblDealerShip ( dealerShipId int(11) NOT NULL AUTO_INCREMENT, dealerShipName varchar (15) DEFAULT NULL, dealerShipState char(2) DEFAULT NULL, dealersName varchar(50) DEFAULT NULL, dealersPhoneNumber varchar (10) DEFAULT NULL, PRIMARY KEY (dealerShipId) ); /* INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (1,'Texans Can Cars','West Virginia','Alicia C. Marinez','239-513-1597'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (2,'Americas Motorsports','Illinois','Dorothy S. Bates','425-437-5686'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (3,'Moose Island Marine','Texas','Alicia C. Marinez','620-386-9845'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (4,'Stadium Lincoln Mercury','New York','Sergio Ochoa','704-602-5603'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (5,'Road Track & Trail','Maine','Chuck Norris','618-975-2136'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (6,'James Motor Cars','Florida','Mike Bay','931-557-1481'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (7,'Thul Auto Stores','Arizona','Allen Woody','205-329-6108'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (8,'Don Roberto Motor Cars','Alaska','Jim Joe','919-625-2474'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (9,'A & W Truck Sales','Pennsylvania','Brittney Mouse','605-584-6291'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (10,'Texas Car','Minnesota','Zoey Dez','585-356-0780'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (11,'Car R Us','West Virginia','Joe Burger','814-490-3312'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (12,'New Cars Four You','West Virginia','Wendy Marks','810-210-1007'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (13,'Car Trades','Connecticut','Mike Mown','239-465-9989'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (14,'BMW Dealers','Montana','Lee Phil','629-751-6598'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (15,'Wheelers','Arizona','Mac Chester','692-914-6523'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (16,'Deals on Wheels','Michigan','Wall lee','256-964-9987'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (17,'Trucks R US','California','Eva Eve','698-985-5641'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (18,'Sporty Sales','Virginia','Crystal Johnson','239-569-5648'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (19,'Used and Mis-used','Washington','Letter Maine','715-412-6957'); INSERT INTO `tbldealership`(`dealerShipId`, `dealerShipName`, `dealerShipState`, `dealersName`, `dealersPhoneNumber`) VALUES (20,'We buy Cars','Ohio','Cris Powers','218-205-0529'); */ CREATE TABLE tblCars ( carId int (11) NOT NULL AUTO_INCREMENT, carMake varchar (50) DEFAULT NULL, carModel varchar (50) DEFAULT NULL, carYear int (4) DEFAULT NULL, dealerShipId int (11) DEFAULT NULL, carSoldDate date DEFAULT NULL, customerId int (11) DEFAULT NULL, PRIMARY KEY (carId) ); CREATE TABLE tblCustomerInfomation ( customerId int (11) NOT NULL AUTO_INCREMENT, customerFirstName varchar (50) DEFAULT NULL, customerLastName varchar (50) DEFAULT NULL, customerPhoneNumber varchar (10) DEFAULT NULL, customerState char (2) DEFAULT NULL, customerAddress varchar (50) DEFAULT NULL, carId int (11) DEFAULT NULL, dealerShipId int (11) DEFAULT NULL, PRIMARY KEY (customerId) ); CREATE TABLE tblCarMaintainceServices ( carShopId int (11) NOT NULL AUTO_INCREMENT, carShopName varchar(50) DEFAULT NULL, carShopState char (2) DEFAULT NULL, carShopAddress varchar (50) DEFAULT NULL, carShopServices varchar (50) DEFAULT NULL, carId int (11) DEFAULT NULL, carShopDateService date DEFAULT NULL, PRIMARY KEY (carShopId) ); CREATE TABLE tblDealerInventory ( dealerLotId int (11) NOT NULL AUTO_INCREMENT, carId int (11) DEFAULT NULL, dealerShipId int (11) DEFAULT NULL, PRIMARY KEY (dealerLotId) );