1

What I try:

player=tester111

id=$(mysql -h "127.0.0.1" -u "myuser" -ppassword "database" -e \
  "SELECT id FROM login WHERE name='$player';")

echo $id

The following output appears:

id 223

How to get ONLY 223 as output?

I am new to stackoverflow, feel free to comment so I can improve my asking skills.

1 Answer 1

3

Use the -N switch when executing your query. -N is for skipping column name and thus you will get only values returned (that is 223 returned) like

id=$(mysql -N -h "127.0.0.1" -u "myuser" -ppassword "database" -e \
  "SELECT id FROM login WHERE name='$player';")
Sign up to request clarification or add additional context in comments.

1 Comment

Epic! Thx alot :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.