Join Bill Weinman for an in-depth discussion in this video Using casts to force type, part of PostgreSQL 9 with PHP Essential Training.
The purpose of a cast is to take a value of one type and force it to another type.…This can come in handy at times, so here's a simple explanation of how it works.…We start by creating a table and it has an integer column and a real column, and…I put the same value into both of them.…A simple 9 digit number, and then I select them from the table.…So when I look at it you see the number on the left, the integer, has all 9…digits, the number on the right has 6 digits and one of them is rounded, you…notice that's 123457 and scientific engineering notation showing that its…times ten to eight.…
So let's go-ahead and cast that left value into a real number and see what…happens. Take this cast string right here.…This is our 05_examples file from the Chapter 5 folder in the exercise files.…And I am just going to paste it in and after this select there, and we will run that.…And we see that now both of numbers are rendering the same way.…So it's as if they were both type real.…So we have the syntax of the cast it has a keyword CAST and then in parentheses…
- Installing PostgreSQL
- Understanding database architecture
- Inserting, updating, and deleting data in a table
- Creating a database library
- Indexing ID fields
- Storing numbers, text, and Boolean values
- Reading data
- Using casts to force type
- Using mathematical functions
- Concatenating strings
- Working with date and time functions and operators
- Defining CRUD
- Using PHP to insert, read, update, and delete rows in a database
Skill Level Beginner
PHP with MySQL Beyond the Basicswith Kevin Skoglund10h 26m Intermediate
1. Quick Start
2. Creating a Database
3. Data Types
4. Storing and Reading Data
5. SQL Expressions
6. Mathematical Functions and Operators
Using math functions3m 2s
7. String Functions and Operators
8. Date and Time Functions and Operators
9. PHP Interfaces
10. Web Applications
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.